Skip to content

Commit

Permalink
Merge pull request #2036 from ERGO-Code/extra-tests
Browse files Browse the repository at this point in the history
Extra tests
  • Loading branch information
galabovaa authored Nov 13, 2024
2 parents 5cdf9ba + 861b7c2 commit 77899c0
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 9 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/build-unit-tests-external.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: build-unit-tests-external

on: [push, pull_request]

jobs:
release_extra_only:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Clone extra unit tests repo
shell: bash
working-directory: ${{runner.workspace}}
run: |
git clone https://github.com/galabovaa/highs-unit-tests.git
- name: Create symlink
shell: bash
working-directory: ${{runner.workspace}}
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 All
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DBUILD_EXTRA_UNIT_TESTS=ON -DBUILD_EXTRA_UNIT_ONLY=ON -DBUILD_CXX=OFF

- name: Build All
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
cmake --build . --parallel
- name: Test Extra Only
working-directory: ${{runner.workspace}}/build
shell: bash
run: ctest --parallel --timeout 300 --output-on-failure

release_all_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Clone extra unit tests repo
shell: bash
working-directory: ${{runner.workspace}}
run: |
git clone https://github.com/galabovaa/highs-unit-tests.git
- name: Create symlink
shell: bash
working-directory: ${{runner.workspace}}
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 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 <NAME>"
# 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,7 @@ CMakeSettings.json
# Nix
.direnv/
result

# Extra unit tests
highs-unit-tests
highs-problem-set
29 changes: 22 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -82,6 +82,21 @@ include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(ALL_TESTS "Build all tests" OFF "BUILD_TESTING;BUILD_CXX" OFF)
message(STATUS "Build all tests: ${ALL_TESTS}")

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")
endif()

option(ZLIB "ZLIB" ON)
message(STATUS "ZLIB: ${ZLIB}")
if (PYTHON_BUILD_SETUP)
Expand Down Expand Up @@ -582,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)
Expand Down
63 changes: 61 additions & 2 deletions check/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -86,7 +86,17 @@ if (NOT FAST_BUILD OR ALL_TESTS)
set(TEST_SOURCES ${TEST_SOURCES} TestSpecialLps.cpp TestLpSolvers.cpp TestMipSolver.cpp)
endif()

if (BUILD_EXTRA_UNIT_TESTS)
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 ${TEST_SOURCES} ${HIGHS_EXTRA_UNIT_TESTS})
message(STATUS ${TEST_SOURCES})
endif()

add_executable(unit_tests ${TEST_SOURCES})

if (UNIX)
target_compile_options(unit_tests PRIVATE "-Wno-unused-variable")
target_compile_options(unit_tests PRIVATE "-Wno-unused-const-variable")
Expand Down Expand Up @@ -397,3 +407,52 @@ if (NOT FAST_BUILD OR ALL_TESTS)
endif()

endif()

if (BUILD_EXTRA_PROBLEM_SET)
list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-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()

0 comments on commit 77899c0

Please sign in to comment.