Skip to content

Commit

Permalink
Allow single test to be specified as an argument to run-nio-alloc-cou…
Browse files Browse the repository at this point in the history
…nter-tests.sh. (#1214)

* Allow single test to be specified as an argument to run-nio-alloc-counter-tests.sh.

Motivation:

run-nio-alloc-counter-tests.sh currently runs all tests. When writing or
debugging a test, you commonly want to run a single test. At the moment the
common practice is to edit the script to hardcode a test to run, which is
annoying and error-prone.

Modifications:

Add an optional argument to the script to specify the test to run.

Result:

$ ./run-nio-alloc-counter-tests.sh

runs all tests.

$ ./run-nio-alloc-counter-tests.sh test_decode_1000_ws_frames.swift

runs only test_decode_1000_ws_frames.swift.
  • Loading branch information
marlimox authored and weissi committed Nov 7, 2019
1 parent 1a9a543 commit bc661cb
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,28 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

tmp_dir="/tmp"

function die() {
echo >&2 "ERROR: $*"
exit 1
}

while getopts "t:" opt; do
case "$opt" in
t)
tmp_dir="$OPTARG"
;;
\?)
die "unknown option $opt"
*)
exit 1
;;
esac
done

shift $((OPTIND-1))

tests_to_run=("$here"/test_*.swift)

if [[ $# -gt 0 ]]; then
tests_to_run=$@
fi

"$here/../../allocation-counter-tests-framework/run-allocation-counter.sh" \
-p "$here/../../.." \
-m NIO -m NIOHTTP1 -m NIOWebSocket \
-s "$here/shared.swift" \
-t "$tmp_dir" \
"$here"/test_*.swift
"${tests_to_run[@]}"

0 comments on commit bc661cb

Please sign in to comment.