Skip to content

Commit

Permalink
fix e2e result junit format
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Fanjul committed Oct 7, 2024
1 parent 6689ec2 commit 3ea1f34
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions images/build-e2e/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ COPY --from=builder /workspace/out/${OS}-${ARCH} ${ASSETS_FOLDER}/bin
COPY --from=builder /workspace/test/e2e/features ${ASSETS_FOLDER}/bin/features
COPY --from=builder /workspace/test/testdata ${ASSETS_FOLDER}/testdata

COPY images/build-e2e/common/* ${ASSETS_FOLDER}/
COPY images/build-e2e/lib/${OS}/* ${ASSETS_FOLDER}/

19 changes: 19 additions & 0 deletions images/build-e2e/common/filter.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="failure">
<xsl:copy>
<xsl:value-of select="@message"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
4 changes: 2 additions & 2 deletions images/build-e2e/lib/darwin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ cd $targetFolder/bin
# Transform results to junit
cd ..
init_line=$(grep -n '<?xml version="1.0" encoding="UTF-8"?>' results/e2e.results | awk '{split($0,n,":"); print n[1]}')
tail -n +$init_line results/e2e.results > results/$junitFilename
tail -n +$init_line results/e2e.results | xsltproc filter.xsl > results/$junitFilename
# Copy logs and diagnose
cp -r bin/out/test-results/* results
cp -r bin/out/test-results/* results
4 changes: 2 additions & 2 deletions images/build-e2e/lib/linux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ cd $targetFolder/bin
# Transform results to junit
cd ..
init_line=$(grep -n '<?xml version="1.0" encoding="UTF-8"?>' results/e2e.results | awk '{split($0,n,":"); print n[1]}')
tail -n +$init_line results/e2e.results > results/$junitFilename
tail -n +$init_line results/e2e.results | xsltproc filter.xsl > results/$junitFilename
# Copy logs and diagnose
cp -r bin/out/test-results/* results
cp -r bin/out/test-results/* results
13 changes: 10 additions & 3 deletions images/build-e2e/lib/windows/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@ mv $targetFolder/bin/e2e.test $targetFolder/bin/e2e.test.exe
# Run e2e
$env:PATH="$env:PATH;$env:HOME\$targetFolder\bin;"
$env:SHELL="powershell"
New-Item -ItemType directory -Path "$env:HOME\$targetFolder\results" -Force
$resultsDir = "$env:HOME\$targetFolder\results"
New-Item -ItemType directory -Path "$resultsDir" -Force

# Run tests
$tags="windows"
if ($e2eTagExpression) {
$tags="$tags && $e2eTagExpression"
}
$dir = "$PWD"
cd $targetFolder\bin
e2e.test.exe --bundle-location=$bundleLocation --pull-secret-file=$env:HOME\$targetFolder\pull-secret --crc-memory=$crcMemory --cleanup-home=false --godog.tags="$tags" --godog.format=junit > $env:HOME\$targetFolder\results\e2e.results

# Transform results to junit
cd ..
$r = Select-String -Pattern '<?xml version="1.0" encoding="UTF-8"?>' -Path results\e2e.results -list -SimpleMatch | select-object -First 1
Get-Content results\e2e.results | Select -skip ($r.LineNumber -1) > results\$junitFilename
$prejunit = "$resultsDir\$junitFilename.pre"
Get-Content "$resultsDir\e2e.results" | Select -skip ($r.LineNumber -1) > "$prejunit"
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform;
$xslt.load("$dir\filter.xsl")
$xslt.transform( "$prejunit", "$resultsDir\$junitFilename" )
rm "$prejunit"
# Copy logs and diagnose
cp -r bin\out\test-results\* results
cp -r bin\out\test-results\* results

0 comments on commit 3ea1f34

Please sign in to comment.