Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 13 additions & 10 deletions tools/reduce_tests.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#!/bin/bash

# A helper script to use multidelta to reduce to a minimal set of tests to
# reproduce a failure.
# A helper script to use delta/singledelta to reduce to a minimal set of
# tests to reproduce a failure.
# Sometimes the tests interact in unexpected ways, so you need to run two
# or three tests in order to cause the failure to occur. It's tiresome to
# determine a minimal subset of tests by hand; this script automates it.

# I think https://github.com/DRMacIver/structureshrink would be better than
# multidelta for this; multidelta requires strange workarounds. But
# multidelta is readily available in most distributions' packages, so using
# that.
# delta for this; delta requires strange workarounds. But delta is readily
# available in most distributions' packages, so using that.

set -ue

if ! which multidelta &>/dev/null
DELTA=singledelta
if !which $DELTA &> /dev/null && which delta &> /dev/null
then
echo "multidelta not found. Please install it to use this script" >&2
DELTA=delta
fi
if ! which $DELTA &> /dev/null
then
echo "delta/singledelta not found. Please install it to use this script" >&2
exit 1
fi

Expand Down Expand Up @@ -60,8 +64,7 @@ export REDUCE_TESTS_TEST_EXE=$test_exe

# We have to add braces around the lines to avoid topformflat messing up the file.
# The braces are removed again inside our helper script.
"$test_exe" --list-test-names-only '~[.]' | \
grep '[^ ]' | sed 's/.*/{&}/' > list_of_tests || true
multidelta tools/reduce_tests_helper.sh list_of_tests
"$test_exe" --list-test-names-only '~[.]' | grep '[^ ]' | sed 's/.*/{&}/' > list_of_tests || true
$DELTA -in_place -test=tools/reduce_tests_helper.sh list_of_tests

# vim:tw=0
10 changes: 9 additions & 1 deletion tools/reduce_tests_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
set -uex

# Disallow empty test list
if [ ! -s "$multidelta_all_files" ]
if [ ! -s "$1" ]
then
exit 1
fi

# return 0 iff the expected error is emitted

# If you have a test string to watch for, add it here and comment out the later check for test success.
#"$REDUCE_TESTS_TEST_EXE" -d yes --rng-seed "$rng_seed" \
# $REDUCE_TESTS_EXTRA_OPTS \
# -f <(tr -d '{}' < <(cat $1)) 2>&1 | tee -a reduce_tests.log | grep -q '../tests/monster_test.cpp:1008: FAILED:'


if "$REDUCE_TESTS_TEST_EXE" -d yes --abort --rng-seed "$rng_seed" \
$REDUCE_TESTS_EXTRA_OPTS \
-f <(tr -d '{}' < "$multidelta_all_files")
Expand Down
Loading