mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Make sure tests are run in CI (#1170)
* Test(CMake) set NAME and COMMAND in add_test * (CMake) add enable_testing() * (CMake) move cmake_dependent_option up, before using them * (CMake) use YAML_CPP_MAIN_PROJECT in cmake_dependent_option * (CMake) log values regarding tests * (CMake) always find CTest, but don't enable tests * (CMAKE)(temp) fix logging * (actions) set YAML_CPP_BUILD_TESTS for tests * (actions) provide YAML_CPP_BUILD_TESTS to ctest * (actions) set -DYAML_CPP_BUILD_TESTS at build * (actions) don't fail false * (actions) build tests in Test step * (actions) run tests verbose * (CMake) remove temp logging * (actions) split building from running tests * (actions) ctest Debug * (actions) ctest Debug * Remove enable_testing
This commit is contained in:

committed by
GitHub

parent
d7f672d141
commit
3ff7ab07ac
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@@ -9,6 +9,7 @@ permissions: read-all
|
|||||||
jobs:
|
jobs:
|
||||||
cmake-build:
|
cmake-build:
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
build: [static, shared]
|
build: [static, shared]
|
||||||
@@ -22,6 +23,7 @@ jobs:
|
|||||||
generator: "MinGW Makefiles"
|
generator: "MinGW Makefiles"
|
||||||
env:
|
env:
|
||||||
YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }}
|
YAML_BUILD_SHARED_LIBS: ${{ matrix.build == 'shared' && 'ON' || 'OFF' }}
|
||||||
|
YAML_CPP_BUILD_TESTS: 'ON'
|
||||||
CMAKE_GENERATOR: >-
|
CMAKE_GENERATOR: >-
|
||||||
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
|
${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -37,9 +39,16 @@ jobs:
|
|||||||
cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }}
|
cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }}
|
||||||
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
|
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
|
||||||
|
|
||||||
- name: Test
|
- name: Build Tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cd build && ctest --output-on-failure
|
run: |
|
||||||
|
cmake ${{ env.CMAKE_GENERATOR }} -S "${{ github.workspace }}" -B build -DYAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} -DYAML_CPP_BUILD_TESTS=${{ env.YAML_CPP_BUILD_TESTS }}
|
||||||
|
cd build && cmake --build . --parallel ${{ steps.cpu-cores.outputs.count }}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd build && ctest -C Debug --output-on-failure --verbose
|
||||||
|
|
||||||
bazel-build:
|
bazel-build:
|
||||||
strategy:
|
strategy:
|
||||||
|
@@ -18,28 +18,24 @@ include(CMakePackageConfigHelpers)
|
|||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
|
option(YAML_CPP_BUILD_CONTRIB "Enable yaml-cpp contrib in library" ON)
|
||||||
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
|
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" ON)
|
||||||
option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
|
option(YAML_BUILD_SHARED_LIBS "Build yaml-cpp shared library" ${BUILD_SHARED_LIBS})
|
||||||
option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT})
|
option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_CPP_MAIN_PROJECT})
|
||||||
option(YAML_CPP_FORMAT_SOURCE "Format source" ON)
|
option(YAML_CPP_FORMAT_SOURCE "Format source" ON)
|
||||||
|
cmake_dependent_option(YAML_CPP_BUILD_TESTS
|
||||||
if (YAML_CPP_BUILD_TESTS)
|
"Enable yaml-cpp tests" OFF
|
||||||
include(CTest)
|
"BUILD_TESTING;YAML_CPP_MAIN_PROJECT" OFF)
|
||||||
endif()
|
cmake_dependent_option(YAML_MSVC_SHARED_RT
|
||||||
|
"MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
|
||||||
|
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF)
|
||||||
|
|
||||||
if (YAML_CPP_FORMAT_SOURCE)
|
if (YAML_CPP_FORMAT_SOURCE)
|
||||||
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
|
find_program(YAML_CPP_CLANG_FORMAT_EXE NAMES clang-format)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_dependent_option(YAML_CPP_BUILD_TESTS
|
|
||||||
"Enable yaml-cpp tests" ON
|
|
||||||
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
|
|
||||||
cmake_dependent_option(YAML_MSVC_SHARED_RT
|
|
||||||
"MSVC: Build yaml-cpp with shared runtime libs (/MD)" ON
|
|
||||||
"CMAKE_SYSTEM_NAME MATCHES Windows" OFF)
|
|
||||||
|
|
||||||
if (YAML_BUILD_SHARED_LIBS)
|
if (YAML_BUILD_SHARED_LIBS)
|
||||||
set(yaml-cpp-type SHARED)
|
set(yaml-cpp-type SHARED)
|
||||||
set(yaml-cpp-label-postfix "shared")
|
set(yaml-cpp-label-postfix "shared")
|
||||||
|
@@ -46,7 +46,7 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_test(yaml-cpp::test yaml-cpp-tests)
|
add_test(NAME yaml-cpp::test COMMAND yaml-cpp-tests)
|
||||||
|
|
||||||
if (build-windows-dll)
|
if (build-windows-dll)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
Reference in New Issue
Block a user