Skip to content

Commit

Permalink
Azure DevOps Testing Results (#830)
Browse files Browse the repository at this point in the history
* ubuntu1604 collect results

* pared back for testing

* fix indentation

* add publish results

* switch to windows

* fix parenthesis

* fix

* adding options to ctest

* fix ci yaml

* debug issue

* tweak

* trying fixes

* trying powershell task instead

* fix xsl path

* uncommented windows build

* move files and update vsts ci yaml

* fix childitem path

* fix jenkins path

* add verbose logging

* Update ctest ps1

* Update .vsts-ci.yml

* Fixing Path Issues

* adjusted path for script

* added cl arg

* parameters for builds

* bugfix

* bugfix

* fix path

* fixing scripts

* update yaml

* filled yml

* Update .vsts-ci.yml

* Update ctest_to_junit.ps1
  • Loading branch information
YoDaMa authored Jan 29, 2019
1 parent e14d640 commit ebbde58
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 3 deletions.
22 changes: 20 additions & 2 deletions build/.vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ phases:
IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT)
DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT)
# PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT)
- script: |
call jenkins\collect_results.cmd iotsdk_win32
- task: PublishTestResults@2
displayName: 'Publish windowsx86 results'
inputs:
testResultsFiles: '**/results-junit.xml'
mergeTestResults: true
testRunTitle: 'windowsx86 Tests'
condition: succeededOrFailed()
- script: cd .. && rd /Q /S $(Agent.BuildDirectory)\s
displayName: 'cleanup'
condition: always()
Expand Down Expand Up @@ -293,8 +302,8 @@ phases:
displayName: 'windowsx64'
steps:
- script: |
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
call jenkins\windows_c.cmd --platform x64
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
call jenkins\windows_c.cmd --platform x64
displayName: 'build'
env:
IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING)
Expand All @@ -313,6 +322,15 @@ phases:
IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT)
DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT)
PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT)
- script: |
call jenkins\collect_results.cmd iotsdk_x64
- task: PublishTestResults@2
displayName: 'Publish windowsx64 results'
inputs:
testResultsFiles: '**/results-junit.xml'
mergeTestResults: true
testRunTitle: 'windowsx64 Tests'
condition: succeededOrFailed()
- script: cd .. && rd /Q /S $(Agent.BuildDirectory)\s
displayName: 'cleanup'
condition: always()
Expand Down
2 changes: 1 addition & 1 deletion build_all/windows/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ if %MAKE_NUGET_PKG% == yes (
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!

if %build-platform% neq arm (
ctest -C "debug" -V -j 8
ctest -T test --no-compress-output -C "debug" -V -j 8
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
)
)
Expand Down
20 changes: 20 additions & 0 deletions jenkins/collect_results.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@REM Copyright (c) Microsoft. All rights reserved.
@REM Licensed under the MIT license. See LICENSE file in the project root for full license information.

setlocal

set working-dir=%~dp0..
rem // resolve to fully qualified path

for %%i in ("%working-dir%") do set working-dir=%%~fi

echo %working-dir%

REM -- C --

pushd "%working-dir%"

Powershell.exe -executionpolicy remotesigned -File %working-dir%\jenkins\ctest_to_junit.ps1 %1
if not %ERRORLEVEL%==0 exit /b %ERRORLEVEL%

popd
15 changes: 15 additions & 0 deletions jenkins/ctest_to_junit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

# This script will be running on working dir set as ./jenkins
$build_folder = $args[0]
$PSScriptRoot
Push-Location $PSScriptRoot
$xsl = Join-Path -Path (Get-Location) -ChildPath "..\jenkins\ctest_to_junit.xsl"
$ctest_xml = (Get-ChildItem "../cmake/$build_folder/*/Test.xml" -Recurse).FullName
$junit_xml = Join-Path -Path (Get-Location) -ChildPath "results-junit.xml"
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load($xsl)
$xslt.Transform($ctest_xml, $junit_xml)

Pop-Location
35 changes: 35 additions & 0 deletions jenkins/ctest_to_junit.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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 ebbde58

Please sign in to comment.