From f1f1b4e0dd35810d9d21b4381f3ca10e624336f7 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 30 Oct 2024 12:32:23 -0700 Subject: [PATCH] Add basic CMake testing to AppVeyor To reduce build time impact we just do a quick smoke test (configure & build). --- appveyor.yml | 8 ++++++ tests/cmake-appveyor.ps1 | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/cmake-appveyor.ps1 diff --git a/appveyor.yml b/appveyor.yml index 9b46193..189b0d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,10 +18,18 @@ build_script: - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\scripts\nuget_build.ps1 2022} test_script: + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\cmake-appveyor.ps1 9 2008 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\cmake-appveyor.ps1 12 2013 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\cmake-appveyor.ps1 14 2015 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\tests\cmake-appveyor.ps1 15 2017 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\tests\cmake-appveyor.ps1 16 2019 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\tests\cmake-appveyor.ps1 17 2022 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\autotest-appveyor.ps1 9 10 11 12 14 } - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\tests\autotest-appveyor.ps1 15 } - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\tests\autotest-appveyor.ps1 19 } - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\tests\autotest-appveyor.ps1 22 } + - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make -j2 config=coverage test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" } - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make -j2 config=coverage defines=PUGIXML_WCHAR_MODE test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" } diff --git a/tests/cmake-appveyor.ps1 b/tests/cmake-appveyor.ps1 new file mode 100644 index 0000000..cedd273 --- /dev/null +++ b/tests/cmake-appveyor.ps1 @@ -0,0 +1,57 @@ +$failed = $FALSE + +$vs = $args[0] +$vsy = $args[1] + +$target = "cmake_vs${vs}_${vsy}" + +Add-AppveyorTest $target -Outcome Running + +mkdir $target +pushd $target + +try +{ + Write-Output "# Setting up CMake VS$vs" + & cmake .. -G "Visual Studio $vs $vsy" | Tee-Object -Variable cmakeOutput + + $sw = [Diagnostics.Stopwatch]::StartNew() + + if ($?) + { + Write-Output "# Building" + + & cmake --build . | Tee-Object -Variable cmakeOutput + + if ($?) + { + Write-Output "# Passed" + + Update-AppveyorTest $target -Outcome Passed -StdOut ($cmakeOutput | out-string) -Duration $sw.ElapsedMilliseconds + } + else + { + Write-Output "# Failed to build" + + Update-AppveyorTest $target -Outcome Failed -StdOut ($cmakeOutput | out-string) -ErrorMessage "Building failed" + + $failed = $TRUE + } + } + else + { + Write-Output "# Failed to configure" + + Update-AppveyorTest $target -Outcome Failed -StdOut ($cmakeOutput | out-string) -ErrorMessage "Configuration failed" + + $failed = $TRUE + } +} +finally +{ + popd +} + +if ($failed) { throw "One or more build steps failed" } + +Write-Output "# End"