Skip to content

Commit

Permalink
Fixed working directory for Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
cschreib committed Aug 19, 2023
1 parent 427ad11 commit d50475d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ set(APPROVAL_TEST_FILES
${PROJECT_SOURCE_DIR}/tests/approval_tests/reporter_console.cpp
${PROJECT_SOURCE_DIR}/tests/approval_tests/reporter_teamcity.cpp)

if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
# For Emcripten, we need the working directory to be where the binaries are created,
# because Emscripten will generate *.data files there that we need to load.
# We don't have access to the filesystem otherwise.
set(APPROVAL_TEST_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(RUNTIME_TEST_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
set(APPROVAL_TEST_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/approval_tests)
set(RUNTIME_TEST_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_tests)
endif()

include(FetchContent)

set(DOCTEST_WITH_MAIN_IN_STATIC_LIB ON)
Expand Down Expand Up @@ -109,7 +120,7 @@ target_compile_definitions(snitch_runtime_tests PUBLIC

add_custom_target(snitch_runtime_tests_run
COMMAND snitch_runtime_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_tests
WORKING_DIRECTORY ${RUNTIME_TEST_WORKING_DIRECTORY}
SOURCES ${RUNTIME_TEST_FILES})
set_target_properties(snitch_runtime_tests_run PROPERTIES EXCLUDE_FROM_ALL True)

Expand Down Expand Up @@ -145,8 +156,8 @@ endif()

add_custom_target(snitch_approval_tests_run
COMMAND snitch_approval_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/approval_tests
SOURCES ${RUNTIME_TEST_FILES})
WORKING_DIRECTORY ${APPROVAL_TEST_WORKING_DIRECTORY}
SOURCES ${APPROVAL_TEST_FILES})
set_target_properties(snitch_approval_tests_run PROPERTIES EXCLUDE_FROM_ALL True)

# Test snitch with itself.
Expand All @@ -171,7 +182,7 @@ target_compile_definitions(snitch_runtime_tests_self PUBLIC

add_custom_target(snitch_runtime_tests_self_run
COMMAND snitch_runtime_tests_self
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_tests
WORKING_DIRECTORY ${RUNTIME_TEST_WORKING_DIRECTORY}
SOURCES ${RUNTIME_TEST_FILES})
set_target_properties(snitch_runtime_tests_self_run PROPERTIES EXCLUDE_FROM_ALL True)

Expand All @@ -194,6 +205,6 @@ target_compile_definitions(snitch_runtime_tests_self_header_only PUBLIC

add_custom_target(snitch_runtime_tests_self_header_only_run
COMMAND snitch_runtime_tests_self_header_only
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_tests
WORKING_DIRECTORY ${RUNTIME_TEST_WORKING_DIRECTORY}
SOURCES ${RUNTIME_TEST_FILES})
set_target_properties(snitch_runtime_tests_self_header_only_run PROPERTIES EXCLUDE_FROM_ALL True)

0 comments on commit d50475d

Please sign in to comment.