diff --git a/.github/workflows/build-unit-tests-external.yml b/.github/workflows/build-unit-tests-external.yml index 0423062c16..a458289de3 100644 --- a/.github/workflows/build-unit-tests-external.yml +++ b/.github/workflows/build-unit-tests-external.yml @@ -2,49 +2,117 @@ name: build-unit-tests-external on: [push, pull_request] -jobs: - release_extra_unit_tests: - runs-on: windows-2019 +jobs: + release_extra_only: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] steps: - uses: actions/checkout@v4 - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/build - - name: Clone extra unit tests repo - working-directory: ${{runner.workspace}}/build - run: git clone https://github.com/galabovaa/highs-unit-tests.git + shell: bash + working-directory: ${{runner.workspace}} + run: | + git clone https://github.com/galabovaa/highs-unit-tests.git - name: Create symlink shell: bash - working-directory: $GITHUB_WORKSPACE/check - run: mklink /d highs-unit-tests ${{runner.workspace}}/highs-unit-tests + working-directory: ${{runner.workspace}} + working-directory: + run: ln -s ${{runner.workspace}}/highs-unit-tests $GITHUB_WORKSPACE/check + + - name: Create Build Environment + run: cmake -E make_directory ${{runner.workspace}}/build - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system + - name: Configure CMake All shell: bash working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DALL_TESTS=ON -DBUILD_EXTRA_UNIT_TESTS=ON + run: cmake $GITHUB_WORKSPACE -DBUILD_EXTRA_UNIT_TESTS=ON -DBUILD_EXTRA_UNIT_ONLY=ON -DBUILD_CXX=OFF - - name: Build + - name: Build All working-directory: ${{runner.workspace}}/build shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config Release --parallel + run: | + cmake --build . --parallel - - name: Unit Test Extra + - name: Test Extra Only working-directory: ${{runner.workspace}}/build shell: bash - run: ./bin/Release/unit_tests.exe highs-names-extra + run: ctest --parallel --timeout 300 --output-on-failure - - name: Test - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest --timeout 300 --output-on-failure -C Release + # release_all_tests: + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # os: [ubuntu-latest] + + # steps: + # - uses: actions/checkout@v4 + + # - name: Create Build Environment + # run: cmake -E make_directory ${{runner.workspace}}/build + + # - name: Configure CMake All + # shell: bash + # working-directory: ${{runner.workspace}}/build + # run: cmake $GITHUB_WORKSPACE -DALL_TESTS=ON -DBUILD_EXTRA_UNIT_TESTS=ON + + # - name: Build All + # working-directory: ${{runner.workspace}}/build + # shell: bash + # run: | + # cmake --build . --parallel + + # - name: Test All + # working-directory: ${{runner.workspace}}/build + # shell: bash + # run: ctest --parallel --timeout 300 --output-on-failure + + # release__windows_extra_unit_tests: + # runs-on: windows-2019 + + # steps: + # - uses: actions/checkout@v4 + + # - name: Create Build Environment + # run: cmake -E make_directory ${{runner.workspace}}/build + + # - name: Clone extra unit tests repo + # working-directory: ${{runner.workspace}}/build + # run: git clone https://github.com/galabovaa/highs-unit-tests.git + + # - name: Create symlink + # shell: bash + # working-directory: $GITHUB_WORKSPACE/check + # run: mklink /d highs-unit-tests ${{runner.workspace}}/highs-unit-tests + + # - name: Configure CMake + # # Use a bash shell so we can use the same syntax for environment variable + # # access regardless of the host operating system + # shell: bash + # working-directory: ${{runner.workspace}}/build + # # Note the current convention is to use the -S and -B options here to specify source + # # and build directories, but this is only available with CMake 3.13 and higher. + # # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + # run: cmake $GITHUB_WORKSPACE -DALL_TESTS=ON -DBUILD_EXTRA_UNIT_TESTS=ON + + # - name: Build + # working-directory: ${{runner.workspace}}/build + # shell: bash + # # Execute the build. You can specify a specific target with "--target " + # run: cmake --build . --config Release --parallel + + # - name: Unit Test Extra + # working-directory: ${{runner.workspace}}/build + # shell: bash + # run: ./bin/Release/unit_tests.exe highs-names-extra + + # - name: Test + # working-directory: ${{runner.workspace}}/build + # shell: bash + # # Execute tests defined by the CMake configuration. + # # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + # run: ctest --timeout 300 --output-on-failure -C Release diff --git a/CMakeLists.txt b/CMakeLists.txt index e0504cb518..c8deeee559 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,11 @@ cmake_minimum_required(VERSION 3.15...3.27) # set preference for clang compiler and intel compiler over gcc and other compilers include(Platform/${CMAKE_SYSTEM_NAME}-Determine-C OPTIONAL) include(Platform/${CMAKE_SYSTEM_NAME}-C OPTIONAL) -set(CMAKE_C_COMPILER_NAMES clang icc cc ${CMAKE_C_COMPILER_NAMES}) +set(CMAKE_C_COMPILER_NAMES clang gcc icx cc ${CMAKE_C_COMPILER_NAMES}) include(Platform/${CMAKE_SYSTEM_NAME}-Determine-CXX OPTIONAL) include(Platform/${CMAKE_SYSTEM_NAME}-CXX OPTIONAL) -set(CMAKE_CXX_COMPILER_NAMES clang++ icpc c++ ${CMAKE_CXX_COMPILER_NAMES}) +set(CMAKE_CXX_COMPILER_NAMES clang++ g++ icpx c++ ${CMAKE_CXX_COMPILER_NAMES}) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -82,11 +82,16 @@ include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(ALL_TESTS "Build all tests" OFF "BUILD_TESTING;BUILD_CXX" OFF) message(STATUS "Build all tests: ${ALL_TESTS}") -CMAKE_DEPENDENT_OPTION(BUILD_EXTRA_UNIT_TESTS "Build extra unit tests" OFF "ALL_TESTS" OFF) +option(BUILD_EXTRA_UNIT_TESTS "Build extra unit tests" OFF) if (BUILD_EXTRA_UNIT_TESTS) message(STATUS "Build extra unit tests: ON") endif() +CMAKE_DEPENDENT_OPTION(BUILD_EXTRA_UNIT_ONLY "Build extra unit tests ONLY" OFF "BUILD_EXTRA_UNIT_TESTS" OFF) +if (BUILD_EXTRA_UNIT_ONLY) + message(STATUS "Build only extra unit tests: ON") +endif() + CMAKE_DEPENDENT_OPTION(BUILD_EXTRA_PROBLEM_SET "Build extra instance tests" OFF "BUILD_TESTING" OFF) if (BUILD_EXTRA_PROBLEM_SET) message(STATUS "Build extra instance tests: ON") @@ -592,14 +597,14 @@ else(FAST_BUILD) if(BUILD_CXX) add_subdirectory(app) - if(BUILD_TESTING) - enable_testing() - add_subdirectory(check) - endif() - # Add tests in examples/tests add_subdirectory(examples) endif() + if(BUILD_TESTING) + enable_testing() + add_subdirectory(check) + endif() + include(python-highs) option(USE_DOTNET_STD_21 "Use .Net Standard 2.1 support" ON) diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt index 428532c323..051b09623a 100644 --- a/check/CMakeLists.txt +++ b/check/CMakeLists.txt @@ -1,6 +1,6 @@ include(CTest) -if (FORTRAN) +if (FORTRAN AND NOT BUILD_EXTRA_UNIT_ONLY) set(CMAKE_Fortran_MODULE_DIRECTORY ${HIGHS_BINARY_DIR}/modules) add_executable(fortrantest TestFortranAPI.f90) if (NOT FAST_BUILD) @@ -13,7 +13,7 @@ if (FORTRAN) ${HIGHS_SOURCE_DIR}/check) endif() -if (NOT FAST_BUILD OR ALL_TESTS) +if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY)) # prepare Catch library set(CATCH_INCLUDE_DIR ${HIGHS_SOURCE_DIR}/extern) add_library(Catch INTERFACE) @@ -413,3 +413,46 @@ if (BUILD_EXTRA_PROBLEM_SET) message(STATUS "${HIGHS_SOURCE_DIR}/check/highs-problem-set") include(highs-problem-set) endif() + +if (BUILD_EXTRA_UNIT_TESTS AND BUILD_EXTRA_UNIT_ONLY) + # prepare Catch library + set(CATCH_INCLUDE_DIR ${HIGHS_SOURCE_DIR}/extern) + add_library(Catch INTERFACE) + target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) + + + list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-unit-tests") + message(STATUS "${HIGHS_SOURCE_DIR}/check/highs-unit-tests") + include(highs-unit-tests) + + set(TEST_SOURCES TestMain.cpp ${HIGHS_EXTRA_UNIT_TESTS}) + message(STATUS ${TEST_SOURCES}) + + add_executable(unit_tests_extra ${TEST_SOURCES}) + target_link_libraries(unit_tests_extra Catch) + + if (BUILD_CXX) + configure_file(${HIGHS_SOURCE_DIR}/check/HCheckConfig.h.in ${HIGHS_BINARY_DIR}/HCheckConfig.h) + target_link_libraries(unit_tests_extra highs) + endif() + + add_test(NAME unit-test-extra-build + COMMAND ${CMAKE_COMMAND} + --build ${HIGHS_BINARY_DIR} + --target unit_tests_extra + # --config ${CMAKE_BUILD_TYPE} + ) + + # Avoid that several build jobs try to concurretly build. + set_tests_properties(unit-test-extra-build + PROPERTIES + RESOURCE_LOCK unittestbin) + + # create a binary running all the tests in the executable + add_test(NAME unit_tests_extra COMMAND unit_tests_extra --success) + set_tests_properties(unit_tests_extra + PROPERTIES + DEPENDS unit-test-extra-build) + set_tests_properties(unit_tests_extra PROPERTIES TIMEOUT 10000) + +endif() \ No newline at end of file