Skip to content

Commit

Permalink
Show test results on Appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
SupSuper committed Mar 11, 2019
1 parent 10c182a commit 29d5845
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
10 changes: 9 additions & 1 deletion appveyor-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ after_build:
before_test:
- 7z e temp\cd.iso.xz -odata\
test_script:
- ctest -V -C %CONFIGURATION%
- ctest -T Test -V --no-compress-output -C %CONFIGURATION%
on_finish:
- ps: |
$testFile = ".\Testing\$(Get-Content Testing\TAG -TotalCount 1)\Test.xml"
$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform
$XSLInputElement.Load((Resolve-Path .\tests\ctest-to-junit.xsl))
$XSLInputElement.Transform((Resolve-Path $testFile), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml"))
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml))
10 changes: 9 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ after_build:
before_test:
- 7z e temp\cd.iso.xz -odata\
test_script:
- ctest -V -C %CONFIGURATION%
- ctest -T Test -V --no-compress-output -C %CONFIGURATION%
on_finish:
- ps: |
$testFile = ".\Testing\$(Get-Content Testing\TAG -TotalCount 1)\Test.xml"
$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform
$XSLInputElement.Load((Resolve-Path .\tests\ctest-to-junit.xsl))
$XSLInputElement.Transform((Resolve-Path $testFile), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml"))
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml))
36 changes: 36 additions & 0 deletions tests/ctest-to-junit.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<testsuites>
<xsl:variable name="buildName" select="//Site/@BuildName"/>
<xsl:variable name="numberOfTests" select="count(//Site/Testing/Test)"/>
<xsl:variable name="numberOfFailures" select="count(//Site/Testing/Test[@Status!='passed'])" />
<testsuite name="CTest"
tests="{$numberOfTests}" time="0"
failures="{$numberOfFailures}" errors="0"
skipped="0">
<xsl:for-each select="//Site/Testing/Test">
<xsl:variable name="testName" select="translate(Name, '-', '_')"/>
<xsl:variable name="duration" select="Results/NamedMeasurement[@name='Execution Time']/Value"/>
<xsl:variable name="status" select="@Status"/>
<xsl:variable name="output" select="Results/Measurement/Value"/>
<xsl:variable name="className" select="translate(Path, '/.', '.')"/>
<testcase classname="projectroot{$className}"
name="{$testName}"
time="{$duration}">
<xsl:if test="@Status!='passed'">
<failure>
<xsl:value-of select="$output" />
</failure>
</xsl:if>
<system-out>
<xsl:value-of select="$output" />
</system-out>
</testcase>
</xsl:for-each>
</testsuite>
</testsuites>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 29d5845

Please sign in to comment.