diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-06-28 13:20:54 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-07-20 19:10:10 +0200 |
commit | d827b11b670f3331e5d924eadfe35c497b08035a (patch) | |
tree | b3dc2ce4d2d31cc7f3d1e831b0c02721083dc552 /ci | |
parent | fe3b5da3ec9bfbca9f2d17ab6d3eddf39516c9c7 (diff) | |
download | libgit2-d827b11b670f3331e5d924eadfe35c497b08035a.tar.gz |
tests: execute leak checker via CTest directly
Right now, we have an awful hack in our test CI setup that extracts the
test command from CTest's output and then prepends the leak checker.
This is dependent on non-machine-parseable output from CMake and also
breaks on various ocassions, like for example when we have spaces in the
current path or when the path contains backslashes. Both conditions may
easily be triggered on Win32 systems, and in fact they do break our
Azure Pipelines builds.
Remove the awful hack in favour of a new CMake build option
"USE_LEAK_CHECKER". If specifying e.g. "-DUSE_LEAK_CHECKER=valgrind",
then we will set up all tests to be run under valgrind. Like this, we
can again simply execute ctest without needing to rely on evil sourcery.
Diffstat (limited to 'ci')
-rwxr-xr-x | ci/test.sh | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/ci/test.sh b/ci/test.sh index cbc3925a9..69b4273a5 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -13,9 +13,6 @@ USER=${USER:-$(whoami)} SUCCESS=1 -VALGRIND="valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions=\"$SOURCE_DIR/libgit2_clar.supp\"" -LEAKS="MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT=\"leaks -quiet \$PPID\"" - cleanup() { echo "Cleaning up..." @@ -32,29 +29,7 @@ cleanup() { echo "Done." } -# Ask ctest what it would run if we were to invoke it directly. This lets -# us manage the test configuration in a single place (tests/CMakeLists.txt) -# instead of running clar here as well. But it allows us to wrap our test -# harness with a leak checker like valgrind. Append the option to write -# JUnit-style XML files. run_test() { - TEST_CMD=$(ctest -N -V -R "^${1}$" | sed -n 's/^[0-9]*: Test command: //p') - - if [ -z "$TEST_CMD" ]; then - echo "Could not find tests: $1" - exit 1 - fi - - TEST_CMD="${TEST_CMD} -r${BUILD_DIR}/results_${1}.xml" - - if [ "$LEAK_CHECK" = "valgrind" ]; then - RUNNER="$VALGRIND $TEST_CMD" - elif [ "$LEAK_CHECK" = "leaks" ]; then - RUNNER="$LEAKS $TEST_CMD" - else - RUNNER="$TEST_CMD" - fi - if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY else @@ -70,7 +45,8 @@ run_test() { fi RETURN_CODE=0 - eval $RUNNER || RETURN_CODE=$? && true + + CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true if [ "$RETURN_CODE" -eq 0 ]; then break |