Skip to content

Commit

Permalink
tests: add make test N= to shared framework
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva authored and cperciva committed Mar 24, 2021
1 parent ba303c0 commit acea39b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 8 additions & 1 deletion tests/shared_test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ scenario_runner() {
## run_scenarios (scenario_filenames):
# Run all scenarios matching ${scenario_filenames}.
run_scenarios() {
# Get the test number(s) to run.
if [ "${N:-0}" -gt "0" ]; then
test_scenarios="$(printf "${scriptdir}/%02d-*.sh" "${N}")"
else
test_scenarios="${scriptdir}/??-*.sh"
fi

# Clean up any previous directory, and create a new one.
prepare_directory

Expand All @@ -284,7 +291,7 @@ run_scenarios() {

printf -- "Running tests\n" 1>&2
printf -- "-------------\n" 1>&2
for scenario in "$@"; do
for scenario in ${test_scenarios}; do
# We can't call this function with $( ... ) because we
# want to allow it to echo values to stdout.
scenario_runner ${scenario}
Expand Down
10 changes: 1 addition & 9 deletions tests/test_libcperciva.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@
scriptdir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
. ${scriptdir}/shared_test_functions.sh


### Project-specific constants and setup

if [ "${N:-0}" -gt "0" ]; then
test_scenarios="$(printf "${scriptdir}/%02d-*.sh" "${N}")"
else
test_scenarios="${scriptdir}/??-*.sh"
fi
out="${bindir}/tests-output"
out_valgrind="${bindir}/tests-valgrind"


### Run tests using project-specific constants
run_scenarios ${test_scenarios}
run_scenarios

0 comments on commit acea39b

Please sign in to comment.