summaryrefslogtreecommitdiffstats
path: root/tests/getopts.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-23 10:12:25 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-23 10:12:25 -0400
commit4c7a49a83e082a7bfff85a9305882f0912655123 (patch)
tree140355e5e30ec2d0414c977441a55a2f5b7100fa /tests/getopts.sh
parenta2af2746c4686201e2e0796fbdfa115d08727b86 (diff)
downloadbfs-4c7a49a83e082a7bfff85a9305882f0912655123.tar.xz
tests: Run test cases in parallel
Diffstat (limited to 'tests/getopts.sh')
-rw-r--r--tests/getopts.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/getopts.sh b/tests/getopts.sh
index 7d3ef4b..d34df4f 100644
--- a/tests/getopts.sh
+++ b/tests/getopts.sh
@@ -52,6 +52,7 @@ EOF
# Parse the command line
parse_args() {
+ JOBS=0
PATTERNS=()
SUDO=()
STOP=0
@@ -64,6 +65,9 @@ parse_args() {
for arg; do
case "$arg" in
+ -j*)
+ JOBS="${arg#-j}"
+ ;;
--bfs=*)
BFS="${arg#*=}"
;;
@@ -127,6 +131,14 @@ parse_args() {
esac
done
+ if ((JOBS == 0)); then
+ if command -v nproc &>/dev/null; then
+ JOBS=$(nproc)
+ else
+ JOBS=1
+ fi
+ fi
+
# Try to resolve the path to $BFS before we cd, while also supporting
# --bfs="./bin/bfs -S ids"
read -a BFS <<<"${BFS:-$BIN/bfs}"