diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ee2bb6..54674a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,4 +38,4 @@ jobs: shell: bash run: | cd build - CTEST_OUTPUT_ON_FAILURE=1 ctest + CTEST_OUTPUT_ON_FAILURE=1 ctest --build-config Debug diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 92d13ab..5c271fb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,7 +30,6 @@ target_sources(clar_test PRIVATE ) target_compile_definitions(clar_test PRIVATE CLAR_FIXTURE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/expected/" - SELFTEST_BINARY_PATH="$" _DARWIN_C_SOURCE _POSIX_C_SOURCE=200809L ) @@ -43,21 +42,15 @@ target_include_directories(clar_test PRIVATE ) target_link_libraries(clar_test clar) -add_test(build_selftest - "${CMAKE_COMMAND}" - --build "${CMAKE_BINARY_DIR}" - --config "$" - --target selftest +add_test(NAME build_selftest + COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --config "$" --target selftest ) set_tests_properties(build_selftest PROPERTIES FIXTURES_SETUP clar_test_fixture) -add_test(build_test - "${CMAKE_COMMAND}" - --build "${CMAKE_BINARY_DIR}" - --config "$" - --target clar_test +add_test(NAME build_test + COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --config "$" --target clar_test ) set_tests_properties(build_test PROPERTIES FIXTURES_SETUP clar_test_fixture) -add_test(clar_test "${CMAKE_CURRENT_BINARY_DIR}/clar_test") +add_test(NAME clar_test COMMAND "${CMAKE_CURRENT_BINARY_DIR}/clar_test" "$") set_tests_properties(clar_test PROPERTIES FIXTURES_REQUIRED clar_test_fixture) diff --git a/test/clar.c b/test/clar.c index 39c10d5..9db3b9f 100644 --- a/test/clar.c +++ b/test/clar.c @@ -3,7 +3,7 @@ #include #include -#include "clar.h" +#include "clar_test.h" #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN @@ -110,7 +110,7 @@ static void run(const char *expected_output_file, int expected_error_code, ...) startup_info.hStdError = stdout_write; startup_info.hStdOutput = stdout_write; startup_info.dwFlags |= STARTF_USESTDHANDLES; - cl_assert_equal_b(1, CreateProcess(SELFTEST_BINARY_PATH, cmdline, NULL, NULL, TRUE, + cl_assert_equal_b(1, CreateProcess(selftest_binary_path, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &startup_info, &process_info)); cl_assert_equal_b(1, CloseHandle(stdout_write)); @@ -210,7 +210,7 @@ static void run(const char *expected_output_file, int expected_error_code, ...) close(pipe_fds[1]) < 0) exit(1); - execv(SELFTEST_BINARY_PATH, (char **) argv); + execv(selftest_binary_path, (char **) argv); exit(1); } else if (pid > 0) { pid_t waited_pid; diff --git a/test/clar_test.h b/test/clar_test.h new file mode 100644 index 0000000..220a350 --- /dev/null +++ b/test/clar_test.h @@ -0,0 +1,3 @@ +#include "clar.h" + +extern const char *selftest_binary_path; diff --git a/test/main.c b/test/main.c index cdbd872..ebf2c51 100644 --- a/test/main.c +++ b/test/main.c @@ -1,4 +1,9 @@ -#include "clar.h" +#include +#include + +#include "clar_test.h" + +const char *selftest_binary_path; #ifdef _WIN32 int __cdecl main(int argc, char *argv[]) @@ -6,5 +11,15 @@ int __cdecl main(int argc, char *argv[]) int main(int argc, char *argv[]) #endif { + if (argc < 2) { + fprintf(stderr, "USAGE: %s \n", + argv[0]); + exit(1); + } + + selftest_binary_path = argv[1]; + memmove(argv, argv + 1, argc); + argc -= 1; + return clar_test(argc, argv); }