From c5c2d931cc0946cb0585e033f5d596b429971d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Mon, 6 May 2024 05:11:38 +0100 Subject: [PATCH 1/3] CMake: Fix running tests on MinGW --- cmake/netcdf_functions_macros.cmake | 8 ++++---- hdf4_test/CMakeLists.txt | 4 ++-- nc_test/CMakeLists.txt | 6 +++--- nc_test4/CMakeLists.txt | 8 +++++--- ncdap_test/CMakeLists.txt | 2 +- ncdump/CMakeLists.txt | 8 ++++---- ncgen/CMakeLists.txt | 4 ++-- nczarr_test/CMakeLists.txt | 8 +++++--- unit_test/CMakeLists.txt | 4 ++-- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/cmake/netcdf_functions_macros.cmake b/cmake/netcdf_functions_macros.cmake index 5a43c2194a..064947bbba 100644 --- a/cmake/netcdf_functions_macros.cmake +++ b/cmake/netcdf_functions_macros.cmake @@ -110,7 +110,7 @@ macro(add_bin_env_temp_large_test prefix F) endif() add_test(${prefix}_${F} bash "-c" "TEMP_LARGE=${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${prefix}_${F}") - if(MSVC) + if(WIN32) set_property(TARGET ${prefix}_${F} PROPERTY FOLDER "tests") set_target_properties(${prefix}_${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -163,7 +163,7 @@ endmacro() macro(add_bin_test_no_prefix F) build_bin_test(${F} ${ARGN}) add_test(${F} ${EXECUTABLE_OUTPUT_PATH}/${F}) - if(MSVC) + if(WIN32) set_property(TEST ${F} PROPERTY FOLDER "tests/") set_target_properties(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -176,7 +176,7 @@ endmacro() # Binary tests which are used by a script looking for a specific name. macro(build_bin_test_no_prefix F) build_bin_test(${F}) - if(MSVC) + if(WIN32) #SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/") set_target_properties(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -201,7 +201,7 @@ macro(add_bin_test prefix F) add_test(${prefix}_${F} ${EXECUTABLE_OUTPUT_PATH}/${prefix}_${F} ) - if(MSVC) + if(WIN32) set_property(TEST ${prefix}_${F} PROPERTY FOLDER "tests/") set_target_properties(${prefix}_${F} PROPERTIES diff --git a/hdf4_test/CMakeLists.txt b/hdf4_test/CMakeLists.txt index b96a5042c8..d935d9d6f3 100644 --- a/hdf4_test/CMakeLists.txt +++ b/hdf4_test/CMakeLists.txt @@ -8,11 +8,11 @@ # Copy some test files from current source dir to out-of-tree build dir. FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -IF(MSVC) +IF(WIN32) FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/) ENDIF() -IF(USE_HDF4_FILE_TESTS AND NOT MSVC) +IF(USE_HDF4_FILE_TESTS AND NOT WIN32) build_bin_test_no_prefix(tst_interops2) build_bin_test_no_prefix(tst_interops3) add_bin_test(hdf4_test tst_chunk_hdf4) diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt index 2bfb8ea626..cee0f68346 100644 --- a/nc_test/CMakeLists.txt +++ b/nc_test/CMakeLists.txt @@ -50,7 +50,7 @@ set_property(TARGET nc_test PROPERTY UNITY_BUILD OFF) # Some extra stand-alone tests SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_utf8_phrases tst_global_fillval tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef tst_default_format) -IF(NOT MSVC) +IF(NOT WIN32) SET(TESTS ${TESTS} tst_utf8_validate) ENDIF() @@ -77,7 +77,7 @@ ENDIF() IF(LARGE_FILE_TESTS) SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large tst_large_cdf5) - IF(NOT MSVC) + IF(NOT WIN32) SET(TESTS ${TESTS} large_files) ENDIF() @@ -134,7 +134,7 @@ ENDIF(NETCDF_BUILD_UTILITIES) # Copy some test files from current source dir to out-of-tree build dir. FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -IF(MSVC) +IF(WIN32) #MESSAGE(STATUS "XXX") #MESSAGE(STATUS "${COPY_FILES}") #MESSAGE(STATUS "${RUNTIME_OUTPUT_DIRECTORY}") diff --git a/nc_test4/CMakeLists.txt b/nc_test4/CMakeLists.txt index d3fae92b02..f190c9c212 100644 --- a/nc_test4/CMakeLists.txt +++ b/nc_test4/CMakeLists.txt @@ -49,7 +49,9 @@ IF(USE_HDF5 AND NETCDF_ENABLE_FILTER_TESTING) build_bin_test(test_filter_order) build_bin_test(test_filter_repeat) build_bin_test(tst_filter_vlen) - ADD_SH_TEST(nc_test4 tst_filter) + if(NOT MINGW) + ADD_SH_TEST(nc_test4 tst_filter) + endif() ADD_SH_TEST(nc_test4 tst_specific_filters) ADD_SH_TEST(nc_test4 tst_bloscfail) ADD_SH_TEST(nc_test4 tst_filter_vlen) @@ -78,7 +80,7 @@ ENDIF(${HDF5_VERSION} VERSION_GREATER "1.10.0") BUILD_BIN_TEST(tst_empty_vlen_unlim) ADD_SH_TEST(nc_test4 run_empty_vlen_test) -IF(NOT MSVC) +IF(NOT WIN32) SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun) ENDIF() @@ -104,7 +106,7 @@ ENDIF() # Copy some test files from current source dir to out-of-tree build dir. FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/ref_bzip2.c ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -IF(MSVC) +IF(WIN32) FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/) ENDIF() diff --git a/ncdap_test/CMakeLists.txt b/ncdap_test/CMakeLists.txt index d1178ff9fc..dcd1c83b26 100644 --- a/ncdap_test/CMakeLists.txt +++ b/ncdap_test/CMakeLists.txt @@ -33,7 +33,7 @@ IF(NETCDF_ENABLE_TESTS) ENDIF(HAVE_BASH) ENDIF() - IF(NOT MSVC) + IF(NOT WIN32) add_bin_env_test(ncdap t_dap3a) add_bin_env_test(ncdap test_cvt) add_bin_env_test(ncdap test_vara) diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt index 64fdfe9c71..d97b2f0802 100644 --- a/ncdump/CMakeLists.txt +++ b/ncdump/CMakeLists.txt @@ -71,11 +71,11 @@ endif(NETCDF_ENABLE_DAP) #### # We have to do a little tweaking # to remove the Release/ and Debug/ directories -# in MSVC builds. This is required to get +# in Windows builds. This is required to get # test scripts to work. #### -if(MSVC) +if(WIN32) macro(setbinprops name) set_target_properties(${name} PROPERTIES @@ -127,7 +127,7 @@ endif() target_link_libraries(tst_fileinfo netcdf ${ALL_TLL_LIBS}) ENDIF() - IF(MSVC) + IF(WIN32) set_target_properties(rewrite-scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -180,7 +180,7 @@ endif() RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR} ) endif(USE_HDF5) - endif(MSVC) + endif(WIN32) # Build support programs build_bin_test_no_prefix(tst_utf8) diff --git a/ncgen/CMakeLists.txt b/ncgen/CMakeLists.txt index 806c52b76a..d8c2e61ec5 100644 --- a/ncgen/CMakeLists.txt +++ b/ncgen/CMakeLists.txt @@ -51,10 +51,10 @@ TARGET_LINK_LIBRARIES(ncgen netcdf ${ALL_TLL_LIBS}) #### # We have to do a little tweaking # to remove the Release/ and Debug/ directories -# in MSVC builds. This is required to get +# in Windows builds. This is required to get # test scripts to work. #### -IF(MSVC) +IF(WIN32) SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) SET_TARGET_PROPERTIES(ncgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG diff --git a/nczarr_test/CMakeLists.txt b/nczarr_test/CMakeLists.txt index d9e7920fd7..a0657d246f 100644 --- a/nczarr_test/CMakeLists.txt +++ b/nczarr_test/CMakeLists.txt @@ -148,7 +148,7 @@ IF(NETCDF_ENABLE_TESTS) TARGET_LINK_LIBRARIES(tst_pure_awssdk ${AWSSDK_CORE_LIB_FILE}) ADD_TEST(tst_pure_awssdk ${EXECUTABLE_PUTPUT_PATH}/tst_pure_awssdk) SET(F tst_pure_awssdk) - IF(MSVC) + IF(WIN32) SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/") SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -156,7 +156,7 @@ IF(NETCDF_ENABLE_TESTS) ${CMAKE_CURRENT_BINARY_DIR}) SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}) - ENDIF(MSVC) + ENDIF(WIN32) SET(CMAKE_CXX_STANDARD ${TMP_CMAKE_CXX_STANDARD}) ENDIF(NETCDF_ENABLE_S3_AWS) @@ -210,7 +210,9 @@ IF(NETCDF_ENABLE_TESTS) build_bin_test(testfilter_order) build_bin_test(testfilter_repeat) ADD_SH_TEST(nczarr_test run_nczfilter) - ADD_SH_TEST(nczarr_test run_filter) + if(NOT MINGW) + ADD_SH_TEST(nczarr_test run_filter) + endif() ADD_SH_TEST(nczarr_test run_specific_filters) ADD_SH_TEST(nczarr_test run_filter_vlen) IF(FALSE) diff --git a/unit_test/CMakeLists.txt b/unit_test/CMakeLists.txt index edfc16cbc0..59f04127c3 100644 --- a/unit_test/CMakeLists.txt +++ b/unit_test/CMakeLists.txt @@ -20,10 +20,10 @@ IF(USE_X_GETOPT) ENDIF() IF(NETCDF_ENABLE_HDF5) - IF(NOT MSVC) + IF(NOT WIN32) add_bin_test(unit_test tst_nclist) add_bin_test(unit_test tst_nc4internal) - ENDIF(NOT MSVC) + ENDIF(NOT WIN32) build_bin_test(tst_reclaim ${XGETOPTSRC}) add_sh_test(unit_test run_reclaim_tests) ENDIF(NETCDF_ENABLE_HDF5) From 7c100f65e5c5c9360892b3160d6298b89ca36f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sat, 4 May 2024 05:43:01 +0100 Subject: [PATCH 2/3] CI: Test on MSYS2/UCRT64 environment see: https://www.msys2.org/docs/environments --- .github/workflows/run_tests_win_mingw.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run_tests_win_mingw.yml b/.github/workflows/run_tests_win_mingw.yml index db0be3748e..73d6000e51 100644 --- a/.github/workflows/run_tests_win_mingw.yml +++ b/.github/workflows/run_tests_win_mingw.yml @@ -6,9 +6,6 @@ name: Run MSYS2, MinGW64-based Tests (Not Visual Studio) -env: - CPPFLAGS: "-D_BSD_SOURCE" - on: [pull_request,workflow_dispatch] concurrency: @@ -20,6 +17,9 @@ jobs: build-and-test-autotools: runs-on: windows-latest + strategy: + matrix: + msystem: [ MINGW64, UCRT64] #, CLANG64 ] defaults: run: shell: msys2 {0} @@ -29,9 +29,10 @@ jobs: - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: - msystem: MINGW64 + msystem: ${{ matrix.msystem }} update: true - install: git mingw-w64-x86_64-toolchain automake libtool autoconf make cmake mingw-w64-x86_64-hdf5 unzip mingw-w64-x86_64-libxml2 mingw-w64-x86_64-zlib + pacboy: cc:p autotools:p hdf5:p curl:p libxml2:p zlib:p blosc:p bzip2:p + install: diffutils m4 git unzip ### # Configure and build From c72360eef154709191740bb945691e7e57c47249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Tue, 7 May 2024 04:45:59 +0100 Subject: [PATCH 3/3] CI: Create an MSYS2/MinGW CMake run. --- .github/workflows/run_tests_win_mingw.yml | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/run_tests_win_mingw.yml b/.github/workflows/run_tests_win_mingw.yml index 73d6000e51..55386900f2 100644 --- a/.github/workflows/run_tests_win_mingw.yml +++ b/.github/workflows/run_tests_win_mingw.yml @@ -74,3 +74,67 @@ jobs: path: | */*.log */*.trs + + build-and-test-cmake: + + runs-on: windows-latest + strategy: + matrix: + msystem: [ MINGW64, UCRT64] #, CLANG64 ] + defaults: + run: + shell: msys2 {0} + + steps: + + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + update: true + pacboy: cc:p cmake:p hdf5:p curl:p libxml2:p zlib:p blosc:p bzip2:p + install: make m4 diffutils git unzip + +### +# Configure and build +### + + - name: (CMake) Configure Build + run: | + LDFLAGS="-Wl,--export-all-symbols" \ + cmake \ + -G"MSYS Makefiles" \ + -B build \ + -S . \ + -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ + -DBUILD_SHARED_LIBS=ON \ + -DNETCDF_ENABLE_NETCDF_4=ON \ + -DNETCDF_ENABLE_DAP=ON \ + -DNETCDF_BUILD_UTILITIES=ON \ + -DNETCDF_ENABLE_TESTS=ON \ + -DNETCDF_ENABLE_HDF5=ON \ + -DNETCDF_ENABLE_DAP=TRUE \ + -DNETCDF_ENABLE_NCZARR=TRUE \ + -DNETCDF_ENABLE_DAP_LONG_TESTS=TRUE \ + -DNETCDF_ENABLE_PLUGINS=ON + if: ${{ success() }} + + - name: (CMake) Look at CMakeCache.txt if error + run: cat build/CMakeCache.txt + if: ${{ failure() }} + + - name: (CMake) Print Summary + run: cat build/libnetcdf.settings + + - name: (CMake) Build All + run: cmake --build build -j$(nproc) + if: ${{ success() }} + + - name: (CMake) Run Tests + run: PATH=$PWD/build:$PATH ctest --test-dir build + if: ${{ success() }} + + - name: (CMake) Verbose output of CTest failures + run: >- + PATH=$PWD/build:$PATH ctest --test-dir build --output-on-failure -j$(nproc) --rerun-failed -VV + if: ${{ failure() }}