Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions test-wheel.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e

my_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
. "$my_dir/python.bash"

Expand All @@ -13,13 +15,30 @@ pip install pytest
cleanup=true

trap '
if [[ -n $(jobs -p) ]]; then
echo "→ Killing $(jobs -p)"
kill $(jobs -p)
fi
failed_pids=()
for pid in $(jobs -p); do
if kill -0 $pid >/dev/null 2>&1; then
# Background process is still running - good.
kill $pid
else
exit_status=$?
if [[ $exit_status -eq 0 ]]; then
echo "Background task $pid already exited with zero status."
else
echo "Background task $pid exited with nonzero status ($exit_status)."
failed_pids+=("$pid")
fi
fi
done

if [[ "$cleanup" == "true" ]]; then
echo "→ Removing $venv"; rm -rf "$venv"
fi

if [[ ${#failed_pids[@]} -gt 0 ]]; then
echo "The following background processes exited with nonzero status: ${failed_pids[@]}"
exit 1
fi
' EXIT

while [[ $# -gt 0 ]]; do
Expand All @@ -31,14 +50,15 @@ while [[ $# -gt 0 ]]; do
shift
;;
-b|--background)
echo "→ Launching Background Task $2 ..."
echo "→ Launching background task: $2"
$2 &
echo "... started with PID: $!"
sleep 5
shift
shift
;;
-f|--foreground)
echo "→ Starting $2 ..."
echo "→ Starting foreground task: $2"
$2
shift
shift
Expand All @@ -51,5 +71,3 @@ while [[ $# -gt 0 ]]; do
;;
esac
done

exit 0