diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0d1219a..8ab761e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,10 +18,12 @@ stages: parameters: jobName: 'Validate GCC latest' imageName: ubuntu-20.04 + CXXVersions: [ 14, 17 ] - template: ./pipelines/jobs.yml parameters: jobName: 'Validate GCC Previous' imageName: ubuntu-18.04 + CXXVersions: [ 14, 17 ] # Clang - stage: Clang @@ -40,6 +42,7 @@ stages: parameters: jobName: 'Validate Clang Previous' imageName: ubuntu-18.04 + CXXVersions: [ 14, 17 ] # MSVC - stage: MSVC @@ -53,6 +56,7 @@ stages: parameters: jobName: 'Validate MSVC Previous' imageName: vs2017-win2016 + CXXVersions: [ 14, 17 ] # Apple-Clang - stage: Apple_Clang @@ -62,7 +66,9 @@ stages: parameters: jobName: 'Validate Apple-Clang latest' imageName: macos-10.15 + CXXVersions: [ 14, 17 ] - template: ./pipelines/jobs.yml parameters: jobName: 'Validate Apple-Clang Previous' imageName: macos-10.14 + CXXVersions: [ 14, 17 ] diff --git a/pipelines/jobs.yml b/pipelines/jobs.yml index dff2f9b..783c46d 100644 --- a/pipelines/jobs.yml +++ b/pipelines/jobs.yml @@ -1,33 +1,19 @@ parameters: jobName: '' imageName: '' + CXXVersions: [ 14, 17, 20 ] + buildTypes: [ 'Debug', 'Release' ] jobs: -- job: - displayName: ${{ parameters.imageName }} - pool: - vmImage: ${{ parameters.imageName }} - strategy: - matrix: - 14_debug: - GSL_CXX_STANDARD: '14' - BUILD_TYPE: 'Debug' - 14_release: - GSL_CXX_STANDARD: '14' - BUILD_TYPE: 'Release' - 17_debug: - GSL_CXX_STANDARD: '17' - BUILD_TYPE: 'Debug' - 17_release: - GSL_CXX_STANDARD: '17' - BUILD_TYPE: 'Release' - # Note: Currently, only some C++20 features are supported by GSL - 20_debug: - GSL_CXX_STANDARD: '20' - BUILD_TYPE: 'Debug' - 20_release: - GSL_CXX_STANDARD: '20' - BUILD_TYPE: 'Release' - continueOnError: false - steps: - - template: ./steps.yml +- ${{ each CXXVersion in parameters.CXXVersions }}: + - ${{ each buildType in parameters.buildTypes }}: + - job: + displayName: ${{ format('{0} {1} C++{2}', parameters.imageName, buildType, CXXVersion) }} + pool: + vmImage: ${{ parameters.imageName }} + continueOnError: false + steps: + - template: ./steps.yml + parameters: + buildType: ${{ buildType }} + CXXVersion: ${{ CXXVersion }} diff --git a/pipelines/steps.yml b/pipelines/steps.yml index b9a4e8c..2e80713 100644 --- a/pipelines/steps.yml +++ b/pipelines/steps.yml @@ -1,9 +1,13 @@ +parameters: + buildType: '' + CXXVersion: '' + steps: - task: CMake@1 name: Configure inputs: workingDirectory: build - cmakeArgs: '-DGSL_CXX_STANDARD=$(GSL_CXX_STANDARD) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -Werror=dev .. ' + cmakeArgs: '-DGSL_CXX_STANDARD=${{ parameters.CXXVersion }} -DCMAKE_BUILD_TYPE=${{ parameters.buildType }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev .. ' - task: CMake@1 name: Build diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 77284b5..dd71105 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,6 +9,10 @@ include(ExternalProject) # will make visual studio generated project group files set_property(GLOBAL PROPERTY USE_FOLDERS ON) +if(CI_TESTING AND GSL_CXX_STANDARD EQUAL 20) + add_compile_definitions(FORCE_STD_SPAN_TESTS=1) +endif() + if(IOS) add_compile_definitions(GTEST_HAS_DEATH_TEST=1 IOS_PROCESS_DELAY_WORKAROUND=1) endif() diff --git a/tests/at_tests.cpp b/tests/at_tests.cpp index 381ab61..93e6b7b 100644 --- a/tests/at_tests.cpp +++ b/tests/at_tests.cpp @@ -119,7 +119,7 @@ TEST(at_tests, InitializerList) EXPECT_DEATH(gsl::at({1, 2, 3, 4}, 4), expected); } -#if defined(__cplusplus) && __cplusplus >= 202002L +#if defined(FORCE_STD_SPAN_TESTS) || defined(__cpp_lib_span) && __cpp_lib_span >= 202002L TEST(at_tests, std_span) { std::vector vec{1, 2, 3, 4, 5}; @@ -145,7 +145,7 @@ TEST(at_tests, std_span) EXPECT_DEATH(gsl::at(csp, -1), expected); EXPECT_DEATH(gsl::at(csp, gsl::narrow_cast(sp.size())), expected); } -#endif // __cplusplus >= 202002L +#endif // defined(FORCE_STD_SPAN_TESTS) || defined(__cpp_lib_span) && __cpp_lib_span >= 202002L #if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER >= 1910 static constexpr bool test_constexpr()