Commit b0d64ffd authored by David Frank's avatar David Frank
Browse files

Use ctests junit reports to improve error output in CI

With this commit, all test binaries use regular console output, and
ctests generates the junit xml report used for nice visual presentation
in GitLab (which was broken since I don't know when, so it should work
again now). Previously, no output was generated, as it was piped to the
test binaries unit report, which made finding errors unnecessary
complex.

Failed tests are rerun again such that the output of these tests is
found at the bottom of the CI log, which should make finding errors a
little easier in the future.
parent d305f316
Pipeline #718896 passed with stages
in 32 minutes and 50 seconds
......@@ -76,6 +76,7 @@ cache:
- build/**/tests/test_*include-*.cmake
- build/**/tests/test_*tests-*.cmake
- build/Testing
- build/junit_report.xml
# Add elsa install to artifact
- install-elsa/include/elsa/**/*.h
......@@ -104,7 +105,7 @@ cache:
script: &buildjob_clang
- mkdir -p build
- cd build
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DELSA_CREATE_JUNIT_REPORTS=ON -DCMAKE_INSTALL_PREFIX="../install-elsa" -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DCMAKE_INSTALL_PREFIX="../install-elsa" -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- ninja
- ninja build-tests
- ninja build-benchmarks
......@@ -115,7 +116,7 @@ cache:
script: &buildjob_normal
- mkdir -p build
- cd build
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DELSA_CREATE_JUNIT_REPORTS=ON -DCMAKE_INSTALL_PREFIX="../install-elsa"
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DCMAKE_INSTALL_PREFIX="../install-elsa"
- ninja
- ninja build-tests
- ninja build-benchmarks
......@@ -128,14 +129,14 @@ cache:
<<: *run_always
script:
- cd build
- ctest --output-on-failure --schedule-random
- ctest --schedule-random --output-junit junit_report.xml || ctest --rerun-failed --output-on-failure
artifacts:
name: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME"
paths:
- build/
expire_in: 60 mins
reports:
junit: "build/test_reports/test_*.xml"
junit: "build/junit_report.xml"
#### Install job templates ####
......@@ -276,7 +277,7 @@ build-gpu-only:
script:
- mkdir -p build
- cd build
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DELSA_CUDA_VECTOR=ON -DELSA_CREATE_JUNIT_REPORTS=ON -DCMAKE_INSTALL_PREFIX="../install-elsa" -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DELSA_CUDA_VECTOR=ON -DCMAKE_INSTALL_PREFIX="../install-elsa" -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- ninja
- ninja build-tests
- ninja build-benchmarks
......@@ -532,7 +533,7 @@ deploy-docs:
script:
- mkdir -p build
- cd build
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DELSA_CREATE_JUNIT_REPORTS=ON -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- cmake .. -GNinja -DELSA_BENCHMARKS=ON -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"
- ninja
- ninja tests
......
......@@ -17,7 +17,6 @@ if(NOT DEFINED ELSA_MASTER_PROJECT)
endif ()
option(ELSA_TESTING "Enable building the unit tests" ${ELSA_MASTER_PROJECT})
option(ELSA_CREATE_JUNIT_REPORTS "Enable creating JUnit style reports when running tests" ON)
option(ELSA_COVERAGE "Enable test coverage computation and reporting" OFF)
option(ELSA_BENCHMARKS "Enable elsa benchmark test cases" OFF)
......
......@@ -71,7 +71,6 @@
"binaryDir": "${sourceDir}/build/",
"cacheVariables": {
"ELSA_BENCHMAKRS": "ON",
"ELSA_CREATE_JUNIT_REPORTS": "ON",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install-elsa"
}
},
......
......@@ -95,14 +95,8 @@ macro(ELSA_DOCTEST name)
add_dependencies(tests ${_testname})
add_dependencies(build-tests ${_testname})
# if we use JUnit reporter handle arguments
if(${ELSA_CREATE_JUNIT_REPORTS})
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/test_reports)
set(ELSA_JUNIT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/test_reports/${_testname}.xml")
endif(${ELSA_CREATE_JUNIT_REPORTS})
# let doctest discover the test and add the JUNIT arguments
doctest_discover_tests(${_testname} JUNIT_OUTPUT_DIR "${ELSA_JUNIT_OUTPUT_DIR}")
# let doctest discover the test
doctest_discover_tests(${_testname})
# Add test to the corresponding fine grained dependency
if(${ELSA_MODULE_TARGET_NAME} STREQUAL "elsa_core")
......
......@@ -118,7 +118,7 @@ if [ "${compiler}" == "-" ]; then
fi
# CMake flags, we'll need at some point, so make them available
CMAKE_FLAGS="-GNinja -DELSA_BENCHMARKS=ON -DELSA_CREATE_JUNIT_REPORTS=ON"
CMAKE_FLAGS="-GNinja -DELSA_BENCHMARKS=ON"
# If we use clang, be sure to use libc++ and libc++abi
if eval ${cxx} --version | grep -q clang ; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment