Skip to content

Commit 77899c0

Browse files
authored
Merge pull request ERGO-Code#2036 from ERGO-Code/extra-tests
Extra tests
2 parents 5cdf9ba + 861b7c2 commit 77899c0

File tree

4 files changed

+215
-9
lines changed

4 files changed

+215
-9
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: build-unit-tests-external
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
release_extra_only:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Clone extra unit tests repo
16+
shell: bash
17+
working-directory: ${{runner.workspace}}
18+
run: |
19+
git clone https://github.com/galabovaa/highs-unit-tests.git
20+
21+
- name: Create symlink
22+
shell: bash
23+
working-directory: ${{runner.workspace}}
24+
run: ln -s ${{runner.workspace}}/highs-unit-tests $GITHUB_WORKSPACE/check
25+
26+
- name: Create Build Environment
27+
run: cmake -E make_directory ${{runner.workspace}}/build
28+
29+
- name: Configure CMake All
30+
shell: bash
31+
working-directory: ${{runner.workspace}}/build
32+
run: cmake $GITHUB_WORKSPACE -DBUILD_EXTRA_UNIT_TESTS=ON -DBUILD_EXTRA_UNIT_ONLY=ON -DBUILD_CXX=OFF
33+
34+
- name: Build All
35+
working-directory: ${{runner.workspace}}/build
36+
shell: bash
37+
run: |
38+
cmake --build . --parallel
39+
40+
- name: Test Extra Only
41+
working-directory: ${{runner.workspace}}/build
42+
shell: bash
43+
run: ctest --parallel --timeout 300 --output-on-failure
44+
45+
release_all_tests:
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
matrix:
49+
os: [ubuntu-latest]
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Clone extra unit tests repo
55+
shell: bash
56+
working-directory: ${{runner.workspace}}
57+
run: |
58+
git clone https://github.com/galabovaa/highs-unit-tests.git
59+
60+
- name: Create symlink
61+
shell: bash
62+
working-directory: ${{runner.workspace}}
63+
run: ln -s ${{runner.workspace}}/highs-unit-tests $GITHUB_WORKSPACE/check
64+
65+
- name: Create Build Environment
66+
run: cmake -E make_directory ${{runner.workspace}}/build
67+
68+
- name: Configure CMake All
69+
shell: bash
70+
working-directory: ${{runner.workspace}}/build
71+
run: cmake $GITHUB_WORKSPACE -DALL_TESTS=ON -DBUILD_EXTRA_UNIT_TESTS=ON
72+
73+
- name: Build All
74+
working-directory: ${{runner.workspace}}/build
75+
shell: bash
76+
run: |
77+
cmake --build . --parallel
78+
79+
- name: Test All
80+
working-directory: ${{runner.workspace}}/build
81+
shell: bash
82+
run: ctest --parallel --timeout 300 --output-on-failure
83+
84+
# release__windows_extra_unit_tests:
85+
# runs-on: windows-2019
86+
87+
# steps:
88+
# - uses: actions/checkout@v4
89+
90+
# - name: Create Build Environment
91+
# run: cmake -E make_directory ${{runner.workspace}}/build
92+
93+
# - name: Clone extra unit tests repo
94+
# working-directory: ${{runner.workspace}}/build
95+
# run: git clone https://github.com/galabovaa/highs-unit-tests.git
96+
97+
# - name: Create symlink
98+
# shell: bash
99+
# working-directory: $GITHUB_WORKSPACE/check
100+
# run: mklink /d highs-unit-tests ${{runner.workspace}}/highs-unit-tests
101+
102+
# - name: Configure CMake
103+
# # Use a bash shell so we can use the same syntax for environment variable
104+
# # access regardless of the host operating system
105+
# shell: bash
106+
# working-directory: ${{runner.workspace}}/build
107+
# # Note the current convention is to use the -S and -B options here to specify source
108+
# # and build directories, but this is only available with CMake 3.13 and higher.
109+
# # The CMake binaries on the Github Actions machines are (as of this writing) 3.12
110+
# run: cmake $GITHUB_WORKSPACE -DALL_TESTS=ON -DBUILD_EXTRA_UNIT_TESTS=ON
111+
112+
# - name: Build
113+
# working-directory: ${{runner.workspace}}/build
114+
# shell: bash
115+
# # Execute the build. You can specify a specific target with "--target <NAME>"
116+
# run: cmake --build . --config Release --parallel
117+
118+
# - name: Unit Test Extra
119+
# working-directory: ${{runner.workspace}}/build
120+
# shell: bash
121+
# run: ./bin/Release/unit_tests.exe highs-names-extra
122+
123+
# - name: Test
124+
# working-directory: ${{runner.workspace}}/build
125+
# shell: bash
126+
# # Execute tests defined by the CMake configuration.
127+
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
128+
# run: ctest --timeout 300 --output-on-failure -C Release

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,7 @@ CMakeSettings.json
283283
# Nix
284284
.direnv/
285285
result
286+
287+
# Extra unit tests
288+
highs-unit-tests
289+
highs-problem-set

CMakeLists.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ cmake_minimum_required(VERSION 3.15...3.27)
99
# set preference for clang compiler and intel compiler over gcc and other compilers
1010
include(Platform/${CMAKE_SYSTEM_NAME}-Determine-C OPTIONAL)
1111
include(Platform/${CMAKE_SYSTEM_NAME}-C OPTIONAL)
12-
set(CMAKE_C_COMPILER_NAMES clang icc cc ${CMAKE_C_COMPILER_NAMES})
12+
set(CMAKE_C_COMPILER_NAMES clang gcc icx cc ${CMAKE_C_COMPILER_NAMES})
1313

1414
include(Platform/${CMAKE_SYSTEM_NAME}-Determine-CXX OPTIONAL)
1515
include(Platform/${CMAKE_SYSTEM_NAME}-CXX OPTIONAL)
16-
set(CMAKE_CXX_COMPILER_NAMES clang++ icpc c++ ${CMAKE_CXX_COMPILER_NAMES})
16+
set(CMAKE_CXX_COMPILER_NAMES clang++ g++ icpx c++ ${CMAKE_CXX_COMPILER_NAMES})
1717

1818
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1919

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

85+
option(BUILD_EXTRA_UNIT_TESTS "Build extra unit tests" OFF)
86+
if (BUILD_EXTRA_UNIT_TESTS)
87+
message(STATUS "Build extra unit tests: ON")
88+
endif()
89+
90+
CMAKE_DEPENDENT_OPTION(BUILD_EXTRA_UNIT_ONLY "Build extra unit tests ONLY" OFF "BUILD_EXTRA_UNIT_TESTS" OFF)
91+
if (BUILD_EXTRA_UNIT_ONLY)
92+
message(STATUS "Build only extra unit tests: ON")
93+
endif()
94+
95+
CMAKE_DEPENDENT_OPTION(BUILD_EXTRA_PROBLEM_SET "Build extra instance tests" OFF "BUILD_TESTING" OFF)
96+
if (BUILD_EXTRA_PROBLEM_SET)
97+
message(STATUS "Build extra instance tests: ON")
98+
endif()
99+
85100
option(ZLIB "ZLIB" ON)
86101
message(STATUS "ZLIB: ${ZLIB}")
87102
if (PYTHON_BUILD_SETUP)
@@ -582,14 +597,14 @@ else(FAST_BUILD)
582597

583598
if(BUILD_CXX)
584599
add_subdirectory(app)
585-
if(BUILD_TESTING)
586-
enable_testing()
587-
add_subdirectory(check)
588-
endif()
589-
# Add tests in examples/tests
590600
add_subdirectory(examples)
591601
endif()
592602

603+
if(BUILD_TESTING)
604+
enable_testing()
605+
add_subdirectory(check)
606+
endif()
607+
593608
include(python-highs)
594609

595610
option(USE_DOTNET_STD_21 "Use .Net Standard 2.1 support" ON)

check/CMakeLists.txt

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include(CTest)
22

3-
if (FORTRAN)
3+
if (FORTRAN AND NOT BUILD_EXTRA_UNIT_ONLY)
44
set(CMAKE_Fortran_MODULE_DIRECTORY ${HIGHS_BINARY_DIR}/modules)
55
add_executable(fortrantest TestFortranAPI.f90)
66
if (NOT FAST_BUILD)
@@ -13,7 +13,7 @@ if (FORTRAN)
1313
${HIGHS_SOURCE_DIR}/check)
1414
endif()
1515

16-
if (NOT FAST_BUILD OR ALL_TESTS)
16+
if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
1717
# prepare Catch library
1818
set(CATCH_INCLUDE_DIR ${HIGHS_SOURCE_DIR}/extern)
1919
add_library(Catch INTERFACE)
@@ -86,7 +86,17 @@ if (NOT FAST_BUILD OR ALL_TESTS)
8686
set(TEST_SOURCES ${TEST_SOURCES} TestSpecialLps.cpp TestLpSolvers.cpp TestMipSolver.cpp)
8787
endif()
8888

89+
if (BUILD_EXTRA_UNIT_TESTS)
90+
list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-unit-tests")
91+
message(STATUS "${HIGHS_SOURCE_DIR}/check/highs-unit-tests")
92+
include(highs-unit-tests)
93+
94+
set(TEST_SOURCES ${TEST_SOURCES} ${HIGHS_EXTRA_UNIT_TESTS})
95+
message(STATUS ${TEST_SOURCES})
96+
endif()
97+
8998
add_executable(unit_tests ${TEST_SOURCES})
99+
90100
if (UNIX)
91101
target_compile_options(unit_tests PRIVATE "-Wno-unused-variable")
92102
target_compile_options(unit_tests PRIVATE "-Wno-unused-const-variable")
@@ -397,3 +407,52 @@ if (NOT FAST_BUILD OR ALL_TESTS)
397407
endif()
398408

399409
endif()
410+
411+
if (BUILD_EXTRA_PROBLEM_SET)
412+
list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-problem-set")
413+
message(STATUS "${HIGHS_SOURCE_DIR}/check/highs-problem-set")
414+
include(highs-problem-set)
415+
endif()
416+
417+
if (BUILD_EXTRA_UNIT_TESTS AND BUILD_EXTRA_UNIT_ONLY)
418+
# prepare Catch library
419+
set(CATCH_INCLUDE_DIR ${HIGHS_SOURCE_DIR}/extern)
420+
add_library(Catch INTERFACE)
421+
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
422+
423+
424+
list(APPEND CMAKE_MODULE_PATH "${HIGHS_SOURCE_DIR}/check/highs-unit-tests")
425+
message(STATUS "${HIGHS_SOURCE_DIR}/check/highs-unit-tests")
426+
include(highs-unit-tests)
427+
428+
set(TEST_SOURCES TestMain.cpp ${HIGHS_EXTRA_UNIT_TESTS})
429+
message(STATUS ${TEST_SOURCES})
430+
431+
add_executable(unit_tests_extra ${TEST_SOURCES})
432+
target_link_libraries(unit_tests_extra Catch)
433+
434+
if (BUILD_CXX)
435+
configure_file(${HIGHS_SOURCE_DIR}/check/HCheckConfig.h.in ${HIGHS_BINARY_DIR}/HCheckConfig.h)
436+
target_link_libraries(unit_tests_extra highs)
437+
endif()
438+
439+
add_test(NAME unit-test-extra-build
440+
COMMAND ${CMAKE_COMMAND}
441+
--build ${HIGHS_BINARY_DIR}
442+
--target unit_tests_extra
443+
# --config ${CMAKE_BUILD_TYPE}
444+
)
445+
446+
# Avoid that several build jobs try to concurretly build.
447+
set_tests_properties(unit-test-extra-build
448+
PROPERTIES
449+
RESOURCE_LOCK unittestbin)
450+
451+
# create a binary running all the tests in the executable
452+
add_test(NAME unit_tests_extra COMMAND unit_tests_extra --success)
453+
set_tests_properties(unit_tests_extra
454+
PROPERTIES
455+
DEPENDS unit-test-extra-build)
456+
set_tests_properties(unit_tests_extra PROPERTIES TIMEOUT 10000)
457+
458+
endif()

0 commit comments

Comments
 (0)