From 880c75746f6d5d0f97bf6d0a48bfcfbfb047f18f Mon Sep 17 00:00:00 2001 From: Snaipe Date: Thu, 20 Aug 2015 08:33:22 +0200 Subject: [PATCH] Fixed comparison tests depending on absolute paths --- samples/CMakeLists.txt | 6 ++++-- samples/asserts.err.expected | 6 +++--- samples/description.err.expected | 2 +- samples/long-messages.err.expected | 2 +- samples/report.err.expected | 2 +- samples/signal.err.expected | 2 +- samples/simple.err.expected | 2 +- samples/tests/run_test.sh | 21 ++++++++++++++------- 8 files changed, 26 insertions(+), 17 deletions(-) mode change 100644 => 100755 samples/tests/run_test.sh diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 49456a8..d6b3fe4 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -35,9 +35,10 @@ foreach(sample ${SAMPLES}) ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) - add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ./${sample} "${CMAKE_CURRENT_LIST_DIR}") + add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . . ${sample}) set_property(TEST ${sample}_compare PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) endforeach() @@ -47,8 +48,9 @@ foreach(script ${SCRIPTS}) ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" ) - add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh ${CMAKE_CURRENT_LIST_DIR}/tests/${script}.sh "${CMAKE_CURRENT_LIST_DIR}") + add_test(${script}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . "${CMAKE_CURRENT_LIST_DIR}" tests/${sample}) set_property(TEST ${script}_compare PROPERTY ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1" + ENVIRONMENT "CRITERION_SHORT_FILENAME=1" ) endforeach() diff --git a/samples/asserts.err.expected b/samples/asserts.err.expected index edb004b..4ad5e0f 100644 --- a/samples/asserts.err.expected +++ b/samples/asserts.err.expected @@ -1,6 +1,6 @@ -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:11: Assertion failed: assert is fatal, expect isn't -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:12: Assertion failed: This assert runs +[----] asserts.c:11: Assertion failed: assert is fatal, expect isn't +[----] asserts.c:12: Assertion failed: This assert runs [FAIL] asserts::base: (0,00s) -[----] /home/snaipe/workspace/c/criterion/samples/asserts.c:20: Assertion failed: The conditions for this test were not met. +[----] asserts.c:20: Assertion failed: The conditions for this test were not met. [FAIL] asserts::old_school: (0,00s) [====] Synthesis: Tested: 6 | Passing: 4 | Failing: 2 | Crashing: 0  diff --git a/samples/description.err.expected b/samples/description.err.expected index b5209d0..33ee4a1 100644 --- a/samples/description.err.expected +++ b/samples/description.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/description.c:4: Assertion failed: 0 +[----] description.c:4: Assertion failed: 0 [FAIL] misc::failing: (0,00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/long-messages.err.expected b/samples/long-messages.err.expected index 2fb7513..2507fbc 100644 --- a/samples/long-messages.err.expected +++ b/samples/long-messages.err.expected @@ -1,4 +1,4 @@ -[----] /home/snaipe/workspace/c/criterion/samples/long-messages.c:4: Assertion failed: This is +[----] long-messages.c:4: Assertion failed: This is [----] A long message [----] Spawning multiple lines. [----] Formatting is respected. diff --git a/samples/report.err.expected b/samples/report.err.expected index e1ca348..e7b9a78 100644 --- a/samples/report.err.expected +++ b/samples/report.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/report.c:5: Assertion failed: 0 +[----] report.c:5: Assertion failed: 0 [FAIL] sample::test: (0,00s) [====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0  diff --git a/samples/signal.err.expected b/samples/signal.err.expected index 5fe1a9b..b0d4c59 100644 --- a/samples/signal.err.expected +++ b/samples/signal.err.expected @@ -1,4 +1,4 @@ -[----] /home/snaipe/workspace/c/criterion/samples/signal.c:16: Unexpected signal caught below this line! +[----] signal.c:16: Unexpected signal caught below this line! [FAIL] simple::uncaught: CRASH! [FAIL] simple::wrong_signal: (0,00s) [====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1  diff --git a/samples/simple.err.expected b/samples/simple.err.expected index 8227be5..2131286 100644 --- a/samples/simple.err.expected +++ b/samples/simple.err.expected @@ -1,3 +1,3 @@ -[----] /home/snaipe/workspace/c/criterion/samples/simple.c:4: Assertion failed: 0 +[----] simple.c:4: Assertion failed: 0 [FAIL] misc::failing: (0,00s) [====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0  diff --git a/samples/tests/run_test.sh b/samples/tests/run_test.sh old mode 100644 new mode 100755 index 88e5d94..501da79 --- a/samples/tests/run_test.sh +++ b/samples/tests/run_test.sh @@ -1,17 +1,24 @@ #!/bin/sh -e -if [ -f $1.in ]; then - sh -c "$1" > $1.out 2> $1.err < $1.in +cmp_dir=$1; shift +out_dir=$1; shift +bin_dir=$1; shift + +mkdir -p $out_dir + +if [ -f $cmp_dir/$1.in ]; then + sh -c "$bin_dir/$*" > $out_dir/$1.out 2> $out_dir/$1.err < $cmp_dir/$1.in else - sh -c "$1" > $1.out 2> $1.err + mkdir -p $(dirname $out_dir/$1) + sh -c "$bin_dir/$*" > $out_dir/$1.out 2> $out_dir/$1.err fi -if [ -f $2/$1.out.expected ] && [ "$(md5sum $1.out | cut -d' ' -f1)" != "$(md5sum $2/$1.out.expected | cut -d' ' -f1)" ]; then - diff $1.out $2/$1.out.expected +if [ -f $cmp_dir/$1.out.expected ] && [ "$(md5sum $out_dir/$1.out | cut -d' ' -f1)" != "$(md5sum $cmp_dir/$1.out.expected | cut -d' ' -f1)" ]; then + diff $out_dir/$1.out $cmp_dir/$1.out.expected exit 255 fi -if [ -f $2/$1.err.expected ] && [ "$(md5sum $1.err | cut -d' ' -f1)" != "$(md5sum $2/$1.err.expected | cut -d' ' -f1)" ]; then - diff $1.err $2/$1.err.expected +if [ -f $cmp_dir/$1.err.expected ] && [ "$(md5sum $out_dir/$1.err | cut -d' ' -f1)" != "$(md5sum $cmp_dir/$1.err.expected | cut -d' ' -f1)" ]; then + diff $out_dir/$1.err $cmp_dir/$1.err.expected exit 255 fi