Skip to content

Commit 0ebc9cd

Browse files
BillyONealNeumann-Aras0219-msftdg0yt
authored
Don't include features from skipped ports in CI runs. (#1822)
Co-authored-by: Alexander Neumann <[email protected]> Co-authored-by: Robert Schumacher <[email protected]> Co-authored-by: Kai Pastor <[email protected]>
1 parent 4819c23 commit 0ebc9cd

35 files changed

+834
-568
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
skipped-depends:arm64-osx=skip
2+
skipped-depends:x64-linux=skip
3+
skipped-depends:x64-osx=skip
4+
skipped-depends:x64-windows=skip
5+
skipped-depends:x86-windows=skip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
message(FATAL_ERROR "This port is skipped and should not be attempted.")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "skipped-depends",
3+
"version": "1.0.0",
4+
"dependencies": [
5+
{
6+
"name": "skipped-features",
7+
"default-features": false,
8+
"features": [
9+
"fail-if-included"
10+
]
11+
}
12+
]
13+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
2+
if ("fail-if-included" IN_LIST FEATURES)
3+
message(FATAL_ERROR "The feature 'fail-if-included' should not be included.")
4+
endif()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "skipped-features",
3+
"version": "1.0.0",
4+
"features": {
5+
"fail-if-included": {
6+
"description": "This feature should cause a failure if it is included in the build."
7+
}
8+
}
9+
}

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

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,59 @@ $Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-
55
Throw-IfNotFailed
66
$ErrorOutput = Run-VcpkgAndCaptureStdErr ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt"
77
Throw-IfNotFailed
8-
if (-not ($Output.Contains("dep-on-feature-not-sup:${Triplet}: cascade"))) {
9-
throw 'dep-on-feature-not-sup must cascade because it depends on a features that is not supported'
10-
}
11-
if (-not ($Output.Contains("not-sup-host-b:${Triplet}: skip"))) {
12-
throw 'not-sup-host-b must be skipped because it is not supported'
13-
}
14-
if (-not ($Output.Contains("feature-not-sup:${Triplet}: *"))) {
15-
throw 'feature-not-sup must be built because the port that causes this port to skip should not be installed'
16-
}
17-
if (-not ($Output.Contains("feature-dep-missing:${Triplet}: *"))) {
18-
throw 'feature-dep-missing must be built because the broken feature is not selected.'
19-
}
8+
# dep-on-feature-not-sup must cascade because it depends on a features that is not supported
9+
Throw-IfNonContains -Actual $Output -Expected "dep-on-feature-not-sup:${Triplet}: cascade"
10+
# not-sup-host-b must be skipped because it is not supported
11+
Throw-IfNonContains -Actual $Output -Expected "not-sup-host-b:${Triplet}: unsupported"
12+
# feature-not-sup must be built because the port that causes this port to skip should not be installed
13+
Throw-IfNonContains -Actual $Output -Expected "feature-not-sup:${Triplet}: *:"
14+
# feature-dep-missing must be built because the broken feature is not selected.
15+
Throw-IfNonContains -Actual $Output -Expected "feature-dep-missing:${Triplet}: *:"
2016
if ($Output.Split("*").Length -ne 4) {
2117
throw 'base-port should not be installed for the host'
2218
}
23-
if (-not ($ErrorOutput.Contains("REGRESSION: not-sup-host-b:${Triplet} is marked as fail but not supported for ${Triplet}."))) {
24-
throw "feature-not-sup's baseline fail entry should result in a regression because the port is not supported"
25-
}
26-
if (-not ($ErrorOutput.Contains("REGRESSION: dep-on-feature-not-sup:${Triplet} is marked as fail but one dependency is not supported for ${Triplet}."))) {
27-
throw "feature-not-sup's baseline fail entry should result in a regression because the port is cascade for this triplet"
28-
}
19+
Throw-IfNonContains -Actual $Output -Expected @"
20+
SUMMARY FOR $Triplet
21+
CASCADED_DUE_TO_MISSING_DEPENDENCIES: 1
22+
EXCLUDED_BY_DRY_RUN: 3
23+
UNSUPPORTED: 1
24+
"@
25+
# feature-not-sup's baseline fail entry should result in a regression because the port is not supported
26+
Throw-IfNonContains -Actual $ErrorOutput -Expected "REGRESSION: not-sup-host-b:${Triplet} is marked as fail but not supported for ${Triplet}."
27+
# feature-not-sup's baseline fail entry should result in a regression because the port is cascade for this triplet
28+
Throw-IfNonContains -Actual $ErrorOutput -Expected "REGRESSION: dep-on-feature-not-sup:${Triplet} is marked as fail but one dependency is not supported for ${Triplet}."
2929

3030
# pass means pass
31-
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt"
31+
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt"
3232
Throw-IfNotFailed
3333
$ErrorOutput = Run-VcpkgAndCaptureStdErr ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.pass.baseline.txt"
3434
Throw-IfNotFailed
35-
if (-not ($ErrorOutput.Contains("REGRESSION: not-sup-host-b:${Triplet} is marked as pass but not supported for ${Triplet}."))) {
36-
throw "feature-not-sup's baseline pass entry should result in a regression because the port is not supported"
37-
}
38-
if (-not ($ErrorOutput.Contains("REGRESSION: dep-on-feature-not-sup:${Triplet} is marked as pass but one dependency is not supported for ${Triplet}."))) {
39-
throw "feature-not-sup's baseline pass entry should result in a regression because the port is cascade for this triplet"
40-
}
35+
# feature-not-sup's baseline pass entry should result in a regression because the port is not supported
36+
Throw-IfNonContains -Actual $ErrorOutput -Expected "REGRESSION: not-sup-host-b:${Triplet} is marked as pass but not supported for ${Triplet}."
37+
# feature-not-sup's baseline pass entry should result in a regression because the port is cascade for this triplet
38+
Throw-IfNonContains -Actual $ErrorOutput -Expected "REGRESSION: dep-on-feature-not-sup:${Triplet} cascaded, but it is required to pass. ("
4139

4240
# any invalid manifest must raise an error
43-
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/broken-manifests" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt"
41+
Remove-Problem-Matchers
42+
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/broken-manifests" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt"
43+
Restore-Problem-Matchers
4444
Throw-IfNotFailed
4545

4646
# test malformed individual overlay port manifest
4747
Remove-Problem-Matchers
4848
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt" --overlay-ports="$PSScriptRoot/../e2e-ports/broken-manifests/malformed"
4949
Restore-Problem-Matchers
5050
Throw-IfNotFailed
51-
if (-not ($Output.Contains("vcpkg.json:3:17: error: Trailing comma"))) {
52-
throw 'malformed port manifest must raise a parsing error'
53-
}
51+
# malformed port manifest must raise a parsing error
52+
Throw-IfNonContains -Actual $Output -Expected "vcpkg.json:3:17: error: Trailing comma"
5453

5554
# test malformed overlay port manifests
5655
Remove-Problem-Matchers
5756
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci.baseline.txt" --overlay-ports="$PSScriptRoot/../e2e-ports/broken-manifests"
5857
Restore-Problem-Matchers
5958
Throw-IfNotFailed
60-
if (-not ($Output.Contains("vcpkg.json:3:17: error: Trailing comma"))) {
61-
throw 'malformed overlay port manifest must raise a parsing error'
62-
}
59+
# malformed overlay manifest must raise a parsing error
60+
Throw-IfNonContains -Actual $Output -Expected "vcpkg.json:3:17: error: Trailing comma"
6361

6462
# test that file conflicts are detected
6563
Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue
@@ -68,8 +66,8 @@ Remove-Problem-Matchers
6866
$emptyDir = "$TestingRoot/empty"
6967
New-Item -ItemType Directory -Path $emptyDir -Force | Out-Null
7068
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$emptyDir" --binarysource=clear --overlay-ports="$PSScriptRoot/../e2e-ports/duplicate-file-a" --overlay-ports="$PSScriptRoot/../e2e-ports/duplicate-file-b"
71-
Throw-IfNotFailed
7269
Restore-Problem-Matchers
70+
Throw-IfNotFailed
7371

7472
# test effect of parent hashes
7573
Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue
@@ -86,6 +84,60 @@ Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue
8684
New-Item -ItemType Directory -Path $installRoot -Force | Out-Null
8785
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci" --binarysource="clear;files,$ArchiveRoot" --parent-hashes="$TestingRoot/parent-hashes.json"
8886
Throw-IfFailed
89-
if ($Output.Contains("base-port:${Triplet}: SUCCEEDED:")) {
90-
throw 'base-port must not be rebuilt again'
87+
# base-port must not be rebuilt again
88+
Throw-IfNonContains -Actual $Output -Expected "base-port:${Triplet}: parent: "
89+
Throw-IfNonContains -Actual $Output -Expected @"
90+
SUMMARY FOR $Triplet
91+
CASCADED_DUE_TO_MISSING_DEPENDENCIES: 1
92+
EXCLUDED_BY_PARENT: 3
93+
UNSUPPORTED: 1
94+
"@
95+
96+
# test that features included only by skipped ports are not included
97+
$xunitFile = Join-Path $TestingRoot 'xunit.xml'
98+
Refresh-TestRoot
99+
Remove-Problem-Matchers
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"
101+
Restore-Problem-Matchers
102+
Throw-IfFailed
103+
if (-not ($Output -match 'skipped-features:[^:]+: \*:' -and $Output -match 'Building skipped-features:[^@]+@1\.0\.0\.\.\.')) {
104+
throw 'did not attempt to build skipped-features'
105+
}
106+
Throw-IfNonContains -Actual $Output -Expected @"
107+
SUMMARY FOR $Triplet
108+
SUCCEEDED: 1
109+
EXCLUDED: 1
110+
"@
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'
91143
}

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
}

include/vcpkg/base/checks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace vcpkg::Checks
3636
}
3737

3838
// If expression is false, call exit_fail.
39+
VCPKG_SAL_ANNOTATION(_Post_satisfies_(_Old_(expression)))
3940
void check_exit(const LineInfo& line_info, bool expression);
4041

4142
// if expression is false, call exit_with_message.

include/vcpkg/base/json.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <vcpkg/base/fwd/files.h>
43
#include <vcpkg/base/fwd/json.h>
54

65
#include <vcpkg/base/expected.h>
@@ -336,7 +335,6 @@ namespace vcpkg::Json
336335
};
337336

338337
ExpectedL<ParsedJson> parse(StringView text, StringView origin);
339-
ParsedJson parse_file(LineInfo li, const ReadOnlyFilesystem&, const Path&);
340338
ExpectedL<Json::Object> parse_object(StringView text, StringView origin);
341339

342340
std::string stringify(const Value&);

include/vcpkg/base/message-data.inc.h

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ DECLARE_MESSAGE(ARegistryPathMustStartWithDollar,
186186
"",
187187
"A registry path must start with `$` to mean the registry root; for example, `$/foo/bar`.")
188188
DECLARE_MESSAGE(ARelaxedVersionString, (), "", "a relaxed version string")
189+
DECLARE_MESSAGE(
190+
RequestedPortsNotInCIPlan,
191+
(),
192+
"",
193+
"one or more ports requested to be installed were not present in the action plan. (Probably a vcpkg bug)")
189194
DECLARE_MESSAGE(ArtifactsBootstrapFailed, (), "", "vcpkg-artifacts is not installed and could not be bootstrapped.")
190195
DECLARE_MESSAGE(ArtifactsOptionIncompatibility, (msg::option), "", "--{option} has no effect on find artifact.")
191196
DECLARE_MESSAGE(ArtifactsOptionJson,
@@ -379,6 +384,11 @@ DECLARE_MESSAGE(BuildResultBuildFailed,
379384
(),
380385
"Printed after the name of an installed entity to indicate that it failed to build.",
381386
"BUILD_FAILED")
387+
DECLARE_MESSAGE(BuildResultCached,
388+
(),
389+
"Printed after the name of an installed entity to indicate that it was not installed because it "
390+
"already existed in a binary cache.",
391+
"CACHED")
382392
DECLARE_MESSAGE(
383393
BuildResultCacheMissing,
384394
(),
@@ -400,6 +410,15 @@ DECLARE_MESSAGE(BuildResultExcluded,
400410
"Printed after the name of an installed entity to indicate that the user explicitly "
401411
"requested it not be installed.",
402412
"EXCLUDED")
413+
DECLARE_MESSAGE(BuildResultExcludedByDryRun,
414+
(),
415+
"Printed after the name of an entity that would be installed, but is not due to --dry-run.",
416+
"EXCLUDED_BY_DRY_RUN")
417+
DECLARE_MESSAGE(BuildResultExcludedByParent,
418+
(),
419+
"Printed after the name of an installed entity to indicate that it isn't tested due to an ABI hash in "
420+
"--parent-hashes.",
421+
"EXCLUDED_BY_PARENT")
403422
DECLARE_MESSAGE(
404423
BuildResultFileConflicts,
405424
(),
@@ -427,6 +446,11 @@ DECLARE_MESSAGE(BuildResultSummaryLine,
427446
(msg::build_result, msg::count),
428447
"Displayed to show a count of results of a build_result in a summary.",
429448
"{build_result}: {count}")
449+
DECLARE_MESSAGE(
450+
BuildResultUnsupported,
451+
(),
452+
"Printed after the name of an installed entity to indicate that it was not included due to a \"supports\" clause.",
453+
"UNSUPPORTED")
430454
DECLARE_MESSAGE(BuildTreesRootDir, (), "", "Buildtrees directory (experimental)")
431455
DECLARE_MESSAGE(BuildTroubleshootingMessage1,
432456
(),
@@ -467,10 +491,6 @@ DECLARE_MESSAGE(CiBaselineDisallowedCascade,
467491
(msg::spec, msg::path),
468492
"",
469493
"REGRESSION: {spec} cascaded, but it is required to pass. ({path}).")
470-
DECLARE_MESSAGE(CiBaselineIndependentRegression,
471-
(msg::spec, msg::build_result),
472-
"",
473-
"REGRESSION: Independent {spec} failed with {build_result}.")
474494
DECLARE_MESSAGE(CiBaselineRegression,
475495
(msg::spec, msg::build_result, msg::path),
476496
"",
@@ -495,10 +515,6 @@ DECLARE_MESSAGE(CiBaselineUnexpectedPass,
495515
(msg::spec, msg::path),
496516
"",
497517
"PASSING, REMOVE FROM FAIL LIST: {spec} ({path}).")
498-
DECLARE_MESSAGE(CiBaselineUnexpectedPassCascade,
499-
(msg::spec, msg::triplet),
500-
"",
501-
"REGRESSION: {spec} is marked as pass but one dependency is not supported for {triplet}.")
502518
DECLARE_MESSAGE(CiBaselineUnexpectedPassUnsupported,
503519
(msg::spec, msg::triplet),
504520
"",

0 commit comments

Comments
 (0)