From 2b3f1e72af1c60647921fae5bc379faf6d7c6d3e Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 8 May 2020 10:57:05 -0400 Subject: [PATCH] Generalize reduce_tests tool Previously it worked only with one test executable, but when building with CMake you might have a different one. Use whichever is the most recently modified. --- tools/reduce_tests.sh | 26 +++++++++++++++++++++++++- tools/reduce_tests_helper.sh | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/reduce_tests.sh b/tools/reduce_tests.sh index fa437673b1508..73a0e98499fef 100755 --- a/tools/reduce_tests.sh +++ b/tools/reduce_tests.sh @@ -37,12 +37,36 @@ shift export REDUCE_TESTS_EXTRA_OPTS="$*" +# Figure out which test executable to use +test_exe= + +for potential_test_exe in ./tests/cata_test ./cata_test ./cata_test-tiles +do + if [ -x "$potential_test_exe" ] + then + if [ -z "$test_exe" -o "$potential_test_exe" -nt "$test_exe" ] + then + test_exe=$potential_test_exe + fi + fi +done + +if [ -z "$test_exe" ] +then + echo "You don't seem to have compiled any test executable" >&2 + exit 1 +else + printf "Using test executable '%s'\n" "$test_exe" +fi + +export REDUCE_TESTS_TEST_EXE=$test_exe + # For some reason the following cata_test command returns 140, rather than 0 (success). # Not sure why. # We have to add braces around the lines to avoid topformflat messing up the file. # The braces are removed again inside our helper script. -./tests/cata_test --list-test-names-only '~[.]' | \ +"$test_exe" --list-test-names-only '~[.]' | \ grep '[^ ]' | sed 's/.*/{&}/' > list_of_tests || true multidelta tools/reduce_tests_helper.sh list_of_tests diff --git a/tools/reduce_tests_helper.sh b/tools/reduce_tests_helper.sh index afa7ff803a44c..ee5ab93297043 100755 --- a/tools/reduce_tests_helper.sh +++ b/tools/reduce_tests_helper.sh @@ -10,7 +10,7 @@ then exit 1 fi -if ./tests/cata_test -d yes --abort --rng-seed "$rng_seed" \ +if "$REDUCE_TESTS_TEST_EXE" -d yes --abort --rng-seed "$rng_seed" \ $REDUCE_TESTS_EXTRA_OPTS \ -f <(tr -d '{}' < "$multidelta_all_files") then