diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 02c5f8d8a..3ac63ecfb 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -46,18 +46,30 @@ jobs: mkdir build pushd build + export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/sparrow-wasm-build export PREFIX=$MAMBA_ROOT_PREFIX/envs/sparrow-wasm-host + export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot emcmake cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_FIND_ROOT_PATH=$PREFIX \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DBUILD_EXAMPLES=OFF \ - -DBUILD_TESTS=OFF \ + -DBUILD_TESTS=ON \ -DBUILD_DOCS=OFF \ + -DSYSROOT_PATH=$SYSROOT_PATH \ .. emmake make -j ${{ env.ncpus }} install - # TODO: Enable tests through subsequent PRs - # - name: Run tests + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '23.x' + + - name: Run tests + shell: bash + working-directory: build/bin/Release + run: | + node --version + node ./test_sparrow_lib.js diff --git a/environment-wasm-host.yml b/environment-wasm-host.yml index 3d714fff7..f50ea9a97 100644 --- a/environment-wasm-host.yml +++ b/environment-wasm-host.yml @@ -2,4 +2,5 @@ name: sparrow-wasm-host channels: - https://repo.prefix.dev/emscripten-forge-dev dependencies: - - howardhinnant_date \ No newline at end of file + - howardhinnant_date + - doctest \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8383744a8..a72065a12 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,19 +47,12 @@ set(SPARROW_TESTS_SOURCES test_arrow_array_schema_utils.cpp test_arrow_array.cpp test_arrow_schema.cpp - test_binary_array.cpp test_bit.cpp test_buffer_adaptor.cpp test_buffer.cpp test_builder_dict_encoded.cpp - test_builder_dict_encoded.cpp test_builder_run_end_encoded.cpp - test_builder_run_end_encoded.cpp - test_builder_utils.cpp test_builder_utils.cpp - test_builder.cpp - test_builder.cpp - test_date_array.cpp test_date_array.cpp test_decimal_array.cpp test_decimal.cpp @@ -91,10 +84,8 @@ set(SPARROW_TESTS_SOURCES test_record_batch.cpp test_repeat_container.cpp test_run_end_encoded_array.cpp - test_string_array.cpp test_struct_array.cpp test_time_array.cpp - test_timestamp_array.cpp test_timestamp_without_timezone_array.cpp test_traits.cpp test_u8_buffer.cpp @@ -105,94 +96,130 @@ set(SPARROW_TESTS_SOURCES test_variable_size_binary_view_array.cpp ) -set(test_target "test_sparrow_lib") -add_executable(${test_target} ${SPARROW_TESTS_SOURCES}) -target_link_libraries(${test_target} - PRIVATE - sparrow - doctest::doctest - better_junit_reporter - $<$:${SANITIZER_LINK_LIBRARIES}>) - -# set(test_target_catch2 "test_sparrow_lib_catch2") - -# add_executable(${test_target_catch2}) -# target_link_libraries(${test_target_catch2} -# PRIVATE -# sparrow -# Catch2::Catch2WithMain -# $<$:${SANITIZER_LINK_LIBRARIES}>) - -# include(Catch) -# catch_discover_tests(${test_target_catch2}) - -include(compile_options) - -target_compile_options(${test_target} - PRIVATE - ${compile_options} - $<$:${SANITIZER_COMPILE_OPTIONS}> - ) -target_link_options(${test_target} - PRIVATE - $<$:${SANITIZER_LINK_OPTIONS}>) -target_compile_definitions(${test_target} - PRIVATE - DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS) - -if(ENABLE_COVERAGE) - enable_coverage(${test_target}) +if(NOT EMSCRIPTEN) + list(APPEND SPARROW_TESTS_SOURCES + test_binary_array.cpp + test_builder.cpp + test_string_array.cpp + test_timestamp_array.cpp + ) endif() -# We do not use non-standard C++ -set_target_properties(${test_target} - PROPERTIES - CMAKE_CXX_EXTENSIONS OFF) -target_compile_features(${test_target} PRIVATE cxx_std_20) - -# target_compile_options(${test_target_catch2} -# PRIVATE -# ${compile_options} -# $<$:${SANITIZER_COMPILE_OPTIONS}> -# ) -# target_link_options(${test_target_catch2} -# PRIVATE -# $<$:${SANITIZER_LINK_OPTIONS}>) -# We do not use non-standard C++ -# set_target_properties(${test_target_catch2} PROPERTIES CMAKE_CXX_EXTENSIONS OFF) -# target_compile_features(${test_target_catch2} PRIVATE cxx_std_20) - -add_custom_target(run_tests - COMMAND ${test_target} - # COMMAND ${test_target_catch2} -v high - DEPENDS - ${test_target} - # ${test_target_catch2} - COMMENT "Running tests for Doctest and Catch2" - USES_TERMINAL -) - -set_target_properties(run_tests PROPERTIES FOLDER "Tests utilities") - -set(JUNIT_REPORT_FILE_DOCTEST ${CMAKE_CURRENT_BINARY_DIR}/test_sparrow_lib_report_doctest.xml) -set(JUNIT_REPORT_FILE_CATCH2 ${CMAKE_CURRENT_BINARY_DIR}/test_sparrow_lib_report_catch2.xml) - -add_custom_target(run_tests_with_junit_report - COMMAND ${test_target} --reporters=better_junit --out=${JUNIT_REPORT_FILE_DOCTEST} --no-path-filenames=true - # COMMAND ${test_target_catch2} --reporter JUnit -o ${JUNIT_REPORT_FILE_CATCH2} - DEPENDS - ${test_target} - # ${test_target_catch2} - COMMENT "Running tests with JUnit reports saved to: ${JUNIT_REPORT_FILE_DOCTEST} and ${JUNIT_REPORT_FILE_CATCH2}" - USES_TERMINAL -) - -set_target_properties(run_tests_with_junit_report PROPERTIES FOLDER "Tests utilities") - -if(ENABLE_INTEGRATION_TEST) - add_subdirectory(c_data_integration) -endif() +set(test_target "test_sparrow_lib") +add_executable(${test_target} ${SPARROW_TESTS_SOURCES}) -if(CREATE_JSON_READER_TARGET) - add_subdirectory(json_reader) +if(EMSCRIPTEN) + + target_compile_options(${test_target} + PUBLIC "SHELL: -fexceptions" + PUBLIC "SHELL: -fPIC" + ) + + target_link_libraries(${test_target} + PRIVATE + sparrow + doctest::doctest + better_junit_reporter) + + target_link_options(${test_target} + PUBLIC "SHELL: -fexceptions" + PUBLIC "SHELL: -fPIC" + PUBLIC "SHELL: -s MAIN_MODULE=1" + PUBLIC "SHELL: -s WASM_BIGINT" + PUBLIC "SHELL: -s ASSERTIONS=0" + PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1" + PUBLIC "SHELL: -s STACK_SIZE=32mb" + PUBLIC "SHELL: -s INITIAL_MEMORY=128mb" + PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include" + ) +else() + target_link_libraries(${test_target} + PRIVATE + sparrow + doctest::doctest + better_junit_reporter + $<$:${SANITIZER_LINK_LIBRARIES}>) + + # set(test_target_catch2 "test_sparrow_lib_catch2") + + # add_executable(${test_target_catch2}) + # target_link_libraries(${test_target_catch2} + # PRIVATE + # sparrow + # Catch2::Catch2WithMain + # $<$:${SANITIZER_LINK_LIBRARIES}>) + + # include(Catch) + # catch_discover_tests(${test_target_catch2}) + + include(compile_options) + + target_compile_options(${test_target} + PRIVATE + ${compile_options} + $<$:${SANITIZER_COMPILE_OPTIONS}> + ) + target_link_options(${test_target} + PRIVATE + $<$:${SANITIZER_LINK_OPTIONS}>) + target_compile_definitions(${test_target} + PRIVATE + DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS) + + if(ENABLE_COVERAGE) + enable_coverage(${test_target}) + endif() + + # We do not use non-standard C++ + set_target_properties(${test_target} + PROPERTIES + CMAKE_CXX_EXTENSIONS OFF) + target_compile_features(${test_target} PRIVATE cxx_std_20) + + # target_compile_options(${test_target_catch2} + # PRIVATE + # ${compile_options} + # $<$:${SANITIZER_COMPILE_OPTIONS}> + # ) + # target_link_options(${test_target_catch2} + # PRIVATE + # $<$:${SANITIZER_LINK_OPTIONS}>) + # We do not use non-standard C++ + # set_target_properties(${test_target_catch2} PROPERTIES CMAKE_CXX_EXTENSIONS OFF) + # target_compile_features(${test_target_catch2} PRIVATE cxx_std_20) + + add_custom_target(run_tests + COMMAND ${test_target} + # COMMAND ${test_target_catch2} -v high + DEPENDS + ${test_target} + # ${test_target_catch2} + COMMENT "Running tests for Doctest and Catch2" + USES_TERMINAL + ) + + set_target_properties(run_tests PROPERTIES FOLDER "Tests utilities") + + set(JUNIT_REPORT_FILE_DOCTEST ${CMAKE_CURRENT_BINARY_DIR}/test_sparrow_lib_report_doctest.xml) + set(JUNIT_REPORT_FILE_CATCH2 ${CMAKE_CURRENT_BINARY_DIR}/test_sparrow_lib_report_catch2.xml) + + add_custom_target(run_tests_with_junit_report + COMMAND ${test_target} --reporters=better_junit --out=${JUNIT_REPORT_FILE_DOCTEST} --no-path-filenames=true + # COMMAND ${test_target_catch2} --reporter JUnit -o ${JUNIT_REPORT_FILE_CATCH2} + DEPENDS + ${test_target} + # ${test_target_catch2} + COMMENT "Running tests with JUnit reports saved to: ${JUNIT_REPORT_FILE_DOCTEST} and ${JUNIT_REPORT_FILE_CATCH2}" + USES_TERMINAL + ) + + set_target_properties(run_tests_with_junit_report PROPERTIES FOLDER "Tests utilities") + + if(ENABLE_INTEGRATION_TEST) + add_subdirectory(c_data_integration) + endif() + + if(CREATE_JSON_READER_TARGET) + add_subdirectory(json_reader) + endif() endif() diff --git a/test/doctest_better_junit/CMakeLists.txt b/test/doctest_better_junit/CMakeLists.txt index c1f06ebb9..afb8a21b8 100644 --- a/test/doctest_better_junit/CMakeLists.txt +++ b/test/doctest_better_junit/CMakeLists.txt @@ -14,3 +14,9 @@ target_include_directories(better_junit_reporter PUBLIC $ ) + +if(EMSCRIPTEN) + target_compile_options(better_junit_reporter + PUBLIC "SHELL: -fPIC" + ) +endif() \ No newline at end of file