Skip to content
Open
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
9 changes: 9 additions & 0 deletions extras/Catch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ function(catch_discover_tests TARGET)
set(_PROPERTIES ${_PROPERTIES} SKIP_RETURN_CODE 4)
endif()

# Emscripten binaries run under node with a virtual filesystem, so a listing
# written to a file never reaches the disk. Read it from stdout instead.
set(_LISTING_TO_STDOUT "")
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(_LISTING_TO_STDOUT ON)
endif()

if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
add_custom_command(
TARGET ${TARGET} POST_BUILD
Expand All @@ -242,6 +249,7 @@ function(catch_discover_tests TARGET)
-D "TEST_DL_FRAMEWORK_PATHS=${_DL_FRAMEWORK_PATHS}"
-D "CTEST_FILE=${ctest_tests_file}"
-D "ADD_TAGS_AS_LABELS=${_ADD_TAGS_AS_LABELS}"
-D "LISTING_TO_STDOUT=${_LISTING_TO_STDOUT}"
-P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
VERBATIM
)
Expand Down Expand Up @@ -288,6 +296,7 @@ function(catch_discover_tests TARGET)
" TEST_DL_PATHS" " [==[" "${_DL_PATHS}" "]==]" "\n"
" TEST_DL_FRAMEWORK_PATHS" " [==[" "${_DL_FRAMEWORK_PATHS}" "]==]" "\n"
" ADD_TAGS_AS_LABELS" " [==[" "${_ADD_TAGS_AS_LABELS}" "]==]" "\n"
" LISTING_TO_STDOUT" " [==[" "${_LISTING_TO_STDOUT}" "]==]" "\n"
" )" "\n"
" endif()" "\n"
" include(\"${ctest_tests_file}\")" "\n"
Expand Down
15 changes: 11 additions & 4 deletions extras/CatchAddTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function(catch_discover_tests_impl)
cmake_parse_arguments(
""
""
"TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE"
"TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE;LISTING_TO_STDOUT"
"TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR;TEST_DL_PATHS;TEST_DL_FRAMEWORK_PATHS;ADD_TAGS_AS_LABELS"
${ARGN}
)
Expand Down Expand Up @@ -286,7 +286,11 @@ function(catch_discover_tests_impl)
set(ENV{DYLD_FRAMEWORK_PATH} "${paths}")
endif()

make_temp_file_path(listing_output_path "${_TEST_WORKING_DIR}")
if(_LISTING_TO_STDOUT)
set(listing_output_path "%stdout")
else()
make_temp_file_path(listing_output_path "${_TEST_WORKING_DIR}")
endif()

set(_Verbosity "quiet")
if (add_tags)
Expand All @@ -312,8 +316,10 @@ function(catch_discover_tests_impl)
endif()

# Read the JSON output back from the output file and validate it.
file(READ ${listing_output_path} listing_output)
file(REMOVE ${listing_output_path})
if(NOT _LISTING_TO_STDOUT)
file(READ ${listing_output_path} listing_output)
file(REMOVE ${listing_output_path})
endif()
validate_input_noescapes(listing_output)

# Prepare reporter
Expand Down Expand Up @@ -546,5 +552,6 @@ if(CMAKE_SCRIPT_MODE_FILE AND DEFINED TEST_EXECUTABLE)
TEST_DL_FRAMEWORK_PATHS ${TEST_DL_FRAMEWORK_PATHS}
CTEST_FILE ${CTEST_FILE}
ADD_TAGS_AS_LABELS ${ADD_TAGS_AS_LABELS}
LISTING_TO_STDOUT ${LISTING_TO_STDOUT}
)
endif()