diff --git a/.appveyor.yml b/.appveyor.yml index f58815908c7..4f32d66362b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -24,6 +24,8 @@ clone_depth: 1 environment: GTEST_FILTER: '-*dump_test_create_dump_*:*NumaSetAffinity:*NumaSetAffinitySuspended:PortSysinfoTest.sysinfo_test0' GTEST_COLOR: '1' + TEST_RESULT_DIR: '%APPVEYOR_BUILD_FOLDER%\test_results' + GTEST_OUTPUT: 'xml:%TEST_RESULT_DIR%\' before_build: - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets" @@ -34,4 +36,6 @@ build: parallel: true test_script: + - cmd: mkdir %TEST_RESULT_DIR% - cmd: ctest -V -C Debug + - ps: scripts\Appveyor-ProcessTests.ps1 diff --git a/scripts/Appveyor-ProcessTests.ps1 b/scripts/Appveyor-ProcessTests.ps1 new file mode 100644 index 00000000000..29b10692bd0 --- /dev/null +++ b/scripts/Appveyor-ProcessTests.ps1 @@ -0,0 +1,31 @@ + +#TODO we need to add the error message (if applicable) to the output +function Process-Tests { + process { + $test_status = "None" + if($_.status -eq "run") { + if($_.failure) { + $test_status = "Failed" + } else { + $test_status = "Passed" + } + } elseif ($_.status -eq "notrun"){ + $test_status = "Skipped" + } + New-Object psobject -Property @{ + 'name' = $_.ParentNode.name + "." + $_.name; + 'status' = $test_status; + 'time' = [long]([float]$_.time * 1000); + 'classname' = $_.classname + } + } +} + +# Writes test results to appveyor dashboard +function Upload-TestResults { + process { + Add-AppveyorTest -Name $_.name -Framework "xUnit" -FileName $_.classname -Outcome $_.status -Duration $_.time + } +} + +$testResults = Select-Xml -Path "$env:TEST_RESULT_DIR\*.xml" //testcase | Select-Object -ExpandProperty Node | Process-Tests | Upload-TestResults