Skip to content

Commit 788d96d

Browse files
committed
Add xunit test.
1 parent 20ea65c commit 788d96d

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

azure-pipelines/end-to-end-tests-dir/ci.ps1

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ SUMMARY FOR $Triplet
9494
"@
9595

9696
# test that features included only by skipped ports are not included
97+
$xunitFile = Join-Path $TestingRoot 'xunit.xml'
9798
Refresh-TestRoot
9899
Remove-Problem-Matchers
99-
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-assets/ci-skipped-features" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci-skipped-features/baseline.txt"
100+
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-assets/ci-skipped-features" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci-skipped-features/baseline.txt" --x-xunit-all --x-xunit="$xunitFile"
100101
Restore-Problem-Matchers
101102
Throw-IfFailed
102103
if (-not ($Output -match 'skipped-features:[^:]+: \*:' -and $Output -match 'Building skipped-features:[^@]+@1\.0\.0\.\.\.')) {
@@ -107,3 +108,36 @@ SUMMARY FOR $Triplet
107108
SUCCEEDED: 1
108109
EXCLUDED: 1
109110
"@
111+
112+
$xunitContent = Get-Content $xunitFile -Raw
113+
$expected = @"
114+
<\?xml version="1\.0" encoding="utf-8"\?><assemblies>
115+
<assembly name="skipped-depends" run-date="\d\d\d\d-\d\d-\d\d" run-time="\d\d:\d\d:\d\d" time="0">
116+
<collection name="$Triplet" time="0">
117+
<test name="skipped-depends:$Triplet" method="skipped-depends:$Triplet" time="0" result="Skip">
118+
<traits>
119+
<trait name="owner" value="$Triplet"/>
120+
</traits>
121+
<reason><!\[CDATA\[EXCLUDED\]\]></reason>
122+
</test>
123+
</collection>
124+
</assembly>
125+
<assembly name="skipped-features" run-date="\d\d\d\d-\d\d-\d\d" run-time="\d\d:\d\d:\d\d" time="0">
126+
<collection name="$Triplet" time="0">
127+
<test name="skipped-features:$Triplet" method="skipped-features\[core\]:$Triplet" time="0" result="Pass">
128+
<traits>
129+
<trait name="abi_tag" value="[^"]+"/>
130+
<trait name="features" value="core"/>
131+
<trait name="owner" value="$Triplet"/>
132+
</traits>
133+
</test>
134+
</collection>
135+
</assembly>
136+
</assemblies>
137+
138+
"@
139+
140+
if (-not ($xunitContent -match $expected)) {
141+
Write-Diff -Actual $xunitContent -Expected $expected
142+
throw 'xUnit output did not match expected output'
143+
}

azure-pipelines/end-to-end-tests-prelude.ps1

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,25 @@ function Set-EmptyTestPort {
234234
git -C $PortsRoot status
235235
}
236236

237+
function Write-Diff {
238+
Param(
239+
[string]$Actual,
240+
[string]$Expected
241+
)
242+
243+
Set-Content -Value $Expected -LiteralPath "$TestingRoot/expected.txt"
244+
Set-Content -Value $Actual -LiteralPath "$TestingRoot/actual.txt"
245+
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
246+
Write-Stack
247+
}
248+
237249
function Throw-IfNonEqual {
238250
Param(
239251
[string]$Actual,
240252
[string]$Expected
241253
)
242254
if ($Actual -ne $Expected) {
243-
Set-Content -Value $Expected -LiteralPath "$TestingRoot/expected.txt"
244-
Set-Content -Value $Actual -LiteralPath "$TestingRoot/actual.txt"
245-
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
246-
Write-Stack
255+
Write-Diff -Actual $Actual -Expected $Expected
247256
throw "Expected '$Expected' but got '$Actual'"
248257
}
249258
}
@@ -261,10 +270,7 @@ function Throw-IfNonEndsWith {
261270
}
262271

263272
if ($actualSuffix -ne $Expected) {
264-
Set-Content -Value $Expected -LiteralPath "$TestingRoot/expected.txt"
265-
Set-Content -Value $Actual -LiteralPath "$TestingRoot/actual.txt"
266-
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
267-
Write-Stack
273+
Write-Diff -Actual $Actual -Expected $Expected
268274
throw "Expected '$Expected' but got '$actualSuffix'"
269275
}
270276
}
@@ -275,10 +281,7 @@ function Throw-IfContains {
275281
[string]$Expected
276282
)
277283
if ($Actual.Contains($Expected)) {
278-
Set-Content -Value $Expected -LiteralPath "$TestingRoot/expected.txt"
279-
Set-Content -Value $Actual -LiteralPath "$TestingRoot/actual.txt"
280-
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
281-
Write-Stack
284+
Write-Diff -Actual $Actual -Expected $Expected
282285
throw "Expected '$Expected' to not be in '$Actual'"
283286
}
284287
}
@@ -289,10 +292,7 @@ function Throw-IfNonContains {
289292
[string]$Expected
290293
)
291294
if (-not ($Actual.Contains($Expected))) {
292-
Set-Content -Value $Expected -LiteralPath "$TestingRoot/expected.txt"
293-
Set-Content -Value $Actual -LiteralPath "$TestingRoot/actual.txt"
294-
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
295-
Write-Stack
295+
Write-Diff -Actual $Actual -Expected $Expected
296296
throw "Expected '$Expected' to be in '$Actual'"
297297
}
298298
}

0 commit comments

Comments
 (0)