Refactored samples for cmake compilation

This commit is contained in:
Snaipe 2015-09-07 01:42:15 +02:00
parent 416b034fe1
commit 496710164e
52 changed files with 95 additions and 49 deletions

View file

@ -6,18 +6,30 @@ endif ()
include_directories(../include)
set(SAMPLES
signal
exit
report
suites
fixtures
asserts
more-suites
long-messages
description
other-crashes
simple
theories
signal.c
exit.c
report.c
suites.c
fixtures.c
asserts.c
more-suites.c
long-messages.c
description.c
other-crashes.c
simple.c
theories.c
signal.cc
exit.cc
report.cc
suites.cc
fixtures.cc
asserts.cc
more-suites.cc
long-messages.cc
description.cc
other-crashes.cc
simple.cc
)
set(SCRIPTS
@ -34,22 +46,15 @@ if (HAVE_PCRE)
endif ()
foreach(sample ${SAMPLES})
add_executable(${sample} ${sample}.c)
target_link_libraries(${sample} criterion)
add_test(${sample} ${sample})
set_property(TEST ${sample} PROPERTY
ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1"
)
add_executable(${sample}_cpp ${sample}.cc)
target_link_libraries(${sample}_cpp criterion)
add_test(${sample}_cpp ${sample}_cpp)
add_executable(${sample}.bin ${sample})
target_link_libraries(${sample}.bin criterion)
add_test(${sample} ${sample}.bin)
set_property(TEST ${sample} PROPERTY
ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1"
)
if (NOT MSVC) # we disable the scripted tests when building with MSVC
add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . . ${sample})
add_test(${sample}_compare sh ${CMAKE_CURRENT_LIST_DIR}/tests/run_test.sh "${CMAKE_CURRENT_LIST_DIR}" . . ${sample}.bin)
set_property(TEST ${sample}_compare PROPERTY
ENVIRONMENT "LC_ALL=en_US.utf8"
ENVIRONMENT "CRITERION_ALWAYS_SUCCEED=1"

View file

@ -1,6 +1,6 @@
[----] asserts.c:11: Assertion failed: assert is fatal, expect isn't
[----] asserts.c:12: Assertion failed: This assert runs
[----] asserts.c:9: Assertion failed: assert is fatal, expect isn't
[----] asserts.c:10: Assertion failed: This assert runs
[FAIL] asserts::base: (0.00s)
[----] asserts.c:20: Assertion failed: The conditions for this test were not met.
[----] asserts.c:18: 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 

View file

@ -0,0 +1,6 @@
[----] asserts.cc:9: Assertion failed: assert is fatal, expect isn't
[----] asserts.cc:10: Assertion failed: This assert runs
[FAIL] asserts::base: (0.00s)
[----] asserts.cc:18: 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 

View file

@ -0,0 +1,3 @@
[----] description.cc:4: Assertion failed: 0
[FAIL] misc::failing: (0.00s)
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -0,0 +1,4 @@
[----] Warning! The test `exit::unexpected_exit` exited during its setup or teardown.
[----] Warning! The test `exit_with_fixtures::fini_exits` exited during its setup or teardown.
[----] Warning! The test `exit_with_fixtures::init_exits` exited during its setup or teardown.
[====] Synthesis: Tested: 5 | Passing: 3 | Failing: 2 | Crashing: 2 

View file

@ -0,0 +1 @@
[====] Synthesis: Tested: 1 | Passing: 1 | Failing: 0 | Crashing: 0 

View file

@ -0,0 +1,2 @@
Runs before the test
Runs after the test

View file

@ -0,0 +1,6 @@
[----] long-messages.cc:4: Assertion failed: This is
[----] A long message
[----] Spawning multiple lines.
[----] Formatting is respected.
[FAIL] sample::long_msg: (0.00s)
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

View file

View file

@ -0,0 +1,3 @@
[----] Warning! The test `misc::setup_crash` crashed during its setup or teardown.
[----] Warning! The test `misc::teardown_crash` crashed during its setup or teardown.
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 1 

View file

@ -0,0 +1,3 @@
[----] report.cc:5: Assertion failed: 0
[FAIL] sample::test: (0.00s)
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -0,0 +1,4 @@
criterion_init
testing test in category sample
Asserts: [1 passed, 1 failed, 2 total]
criterion_fini

View file

View file

@ -0,0 +1,4 @@
[----] signal.cc: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 

View file

View file

View file

@ -0,0 +1,3 @@
[----] simple.cc:4: Assertion failed: 0
[FAIL] misc::failing: (0.00s)
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0 

View file

View file

@ -0,0 +1 @@
[====] Synthesis: Tested: 2 | Passing: 2 | Failing: 0 | Crashing: 0 

View file

View file

@ -0,0 +1 @@
[====] Synthesis: Tested: 2 | Passing: 2 | Failing: 0 | Crashing: 0 

View file

View file

@ -1,3 +1,3 @@
#!/bin/sh
./simple --no-early-exit --always-succeed
./theories --no-early-exit --always-succeed
./simple.c.bin --no-early-exit --always-succeed
./theories.c.bin --no-early-exit --always-succeed

View file

@ -1,2 +1,2 @@
#!/bin/sh
./simple --fail-fast --always-succeed
./simple.c.bin --fail-fast --always-succeed

View file

@ -1,3 +1,3 @@
#!/bin/sh
./simple --help
./simple --version
./simple.c.bin --help
./simple.c.bin --version

View file

@ -1,3 +1,3 @@
#!/bin/sh
./simple --list
./simple --list --ascii
./simple.c.bin --list
./simple.c.bin --list --ascii

View file

@ -1,10 +1,10 @@
#!/bin/sh -e
./simple --pattern '*/passing'
./simple --pattern '!(*/passing)'
./simple --pattern '[pf]a@(ss|il)ing'
./simple --pattern '@(+(nest)ed))'
./simple --pattern '?(*(a|b))'
! ./simple --pattern '?(malformed'
./simple --pattern '[!azerty]assing'
./simple --pattern '|pipe'
./simple --pattern '\!(escaped'
./simple.c.bin --pattern '*/passing'
./simple.c.bin --pattern '!(*/passing)'
./simple.c.bin --pattern '[pf]a@(ss|il)ing'
./simple.c.bin --pattern '@(+(nest)ed))'
./simple.c.bin --pattern '?(*(a|b))'
! ./simple.c.bin --pattern '?(malformed'
./simple.c.bin --pattern '[!azerty]assing'
./simple.c.bin --pattern '|pipe'
./simple.c.bin --pattern '\!(escaped'

View file

@ -1,7 +1,7 @@
#!/bin/sh
./simple --tap --always-succeed
./signal --tap --always-succeed
./asserts --tap --always-succeed
./more-suites --tap --always-succeed
./long-messages --tap --always-succeed
./description --tap --always-succeed
./simple.c.bin --tap --always-succeed
./signal.c.bin --tap --always-succeed
./asserts.c.bin --tap --always-succeed
./more-suites.c.bin --tap --always-succeed
./long-messages.c.bin --tap --always-succeed
./description.c.bin --tap --always-succeed

View file

@ -1,2 +1,2 @@
#!/bin/sh
./simple --verbose --always-succeed
./simple.c.bin --verbose --always-succeed