Skip to content

Commit cf39054

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/cache-compiler-hash-2
2 parents 00fd53b + 52e8ac9 commit cf39054

File tree

82 files changed

+4785
-2351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4785
-2351
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Param([string]$File)
2+
Write-Host "Creating file with the wrong hash"
3+
Set-Content -Path $File -Value "This is a file with the wrong hash" -Encoding Ascii -NoNewline
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
throw "Script download error"
1+
Write-Host "Script download error"
2+
exit 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Write-Host "Not creating a file"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"overlay-ports": [ "." ]
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": [
3+
"a"
4+
]
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "a",
3+
"version": "0"
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This port is intentionally malformed and should not be loaded, because ../../a should be loaded instead
2+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "a",
3+
"version": "0",
4+
"intentionally-malformed"
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$comment": "'config-overlays/a' in . should get loaded first, so we should never consider 'config-overlays/malformed/a'",
3+
"overlay-ports": [ "config-overlays", "config-overlays/malformed" ]
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": [
3+
"a"
4+
]
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file exists only to ensure that git creates the directory containing it, so that ./hello/.. is a valid path.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"overlay-ports": [ "./hello/.." ]
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": [
3+
"a"
4+
]
5+
}

azure-pipelines/end-to-end-tests-dir/asset-caching.ps1

Lines changed: 337 additions & 98 deletions
Large diffs are not rendered by default.

azure-pipelines/end-to-end-tests-dir/commands.extract.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if (-Not (Test-Path $extractedFilePath)) {
1212

1313
if (-Not $IsWindows) {
1414
$unixMode = (Get-Item $extractedFilePath).UnixMode
15-
if ($unixMode -ne "-rwxr-xr-x") {
16-
throw "File does not have +x permission. UnixMode: $unixMode"
15+
if (-not ($unixMode -match 'x.*x.*x')) {
16+
throw "File does not have +x permission. $extractedFilePath UnixMode: $unixMode"
1717
}
1818
}
1919

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$VcpkgToolsJsonSchemaFile = (Get-Item "$PSScriptRoot/../../docs/vcpkg-tools.schema.json").FullName
44
if (-not (Test-Json -ea:0 -LiteralPath "$VcpkgRoot/scripts/vcpkg-tools.json" -SchemaFile $VcpkgToolsJsonSchemaFile)) {
5-
throw "real vcpkg-tools.json doesn't conform to schema"
5+
throw "real vcpkg-tools.json doesn't conform to schema"
66
}
77

88
if (-not $IsMacOS -and -not $IsLinux) {
@@ -20,7 +20,7 @@ if (-not $IsMacOS -and -not $IsLinux) {
2020
{
2121
"schema-version": 1,
2222
"tools": [{
23-
"name": "7zip",
23+
"name": "7zip_msi",
2424
"os": "windows",
2525
"version": "19.00",
2626
"executable": "Files\\7-Zip\\7z.exe",
@@ -86,13 +86,13 @@ if (-not $IsMacOS -and -not $IsLinux) {
8686
'@ | % { $_ -replace "`r","" } | Out-File -enc ascii $VcpkgToolsJson
8787

8888
if (-not (Test-Json -ea:0 -LiteralPath $VcpkgToolsJson -SchemaFile $VcpkgToolsJsonSchemaFile)) {
89-
throw "testing vcpkg-tools.json doesn't conform to schema"
89+
throw "testing vcpkg-tools.json doesn't conform to schema"
9090
}
9191

9292
$env:VCPKG_DOWNLOADS = Join-Path $TestingRoot 'down loads'
93-
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "7zip", "--vcpkg-root=$TestingRoot"))
93+
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "7zip_msi", "--vcpkg-root=$TestingRoot"))
9494
Throw-IfFailed
95-
Require-FileExists "$env:VCPKG_DOWNLOADS/tools/7zip-19.00-windows/Files/7-Zip/7z.exe"
95+
Require-FileExists "$env:VCPKG_DOWNLOADS/tools/7zip_msi-19.00-windows/Files/7-Zip/7z.exe"
9696

9797
Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja-testing", "--vcpkg-root=$TestingRoot"))
9898
Throw-IfFailed

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

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Tests a simple project with overlay ports and triplets configured on a vcpkg-configuration.json file
44
Copy-Item -Recurse -LiteralPath @(
5-
"$PSScriptRoot/../e2e-projects/overlays-project-with-config",
5+
"$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing",
66
"$PSScriptRoot/../e2e-projects/overlays-project-config-embedded",
7-
"$PSScriptRoot/../e2e-projects/overlays-bad-paths"
7+
"$PSScriptRoot/../e2e-projects/overlays-project-with-config"
88
) $TestingRoot
99

1010
$manifestRoot = "$TestingRoot/overlays-project-with-config"
@@ -27,13 +27,32 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot `
2727
--triplet fancy-config-embedded-triplet
2828
Throw-IfFailed
2929

30+
# ... and with command line overlay-ports being 'dot'
31+
pushd "$manifestRoot/cli-overlays"
32+
try {
33+
Run-Vcpkg install --x-manifest-root=$manifestRoot `
34+
--overlay-ports=. `
35+
--overlay-triplets=$manifestRoot/my-triplets `
36+
--x-install-root=$installRoot `
37+
--triplet fancy-config-embedded-triplet
38+
Throw-IfFailed
39+
} finally {
40+
popd
41+
}
42+
3043
# Config with bad paths
31-
$manifestRoot = "$TestingRoot/overlays-bad-paths"
44+
$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-bad-paths"
3245
$env:VCPKG_OVERLAY_PORTS = "$manifestRoot/env_overlays"
3346
Run-Vcpkg install --x-manifest-root=$manifestRoot `
3447
--overlay-triplets=$manifestRoot/my-triplets `
3548
--x-install-root=$installRoot
3649
Throw-IfNotFailed
50+
Remove-Item env:VCPKG_OVERLAY_PORTS
51+
52+
# Test that once an overlay port is loaded for a name, subsequent ports are not considered
53+
$manifestRoot = "$TestingRoot/overlays-malformed-shadowing"
54+
Run-Vcpkg install --x-manifest-root=$manifestRoot
55+
Throw-IfFailed
3756

3857
# Test overlay_triplet paths remain relative to the manifest root after x-update-baseline
3958
$manifestRoot = "$TestingRoot/overlays-project-with-config"
@@ -47,11 +66,27 @@ $overlaysAfter = $configurationAfter."overlay-triplets"
4766
$notEqual = @(Compare-Object $overlaysBefore $overlaysAfter -SyncWindow 0).Length -ne 0
4867

4968
if ($notEqual) {
50-
Throw "Overlay triplets paths changed after x-update-baseline"
69+
Throw "Overlay triplets paths changed after x-update-baseline"
5170
}
5271

72+
# Test that trying to declare overlay-ports as '.' fails
73+
$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-dot"
74+
$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot
75+
Throw-IfNotFailed
76+
Throw-IfNonContains -Actual $output -Expected @"
77+
error: The manifest directory cannot be the same as a directory configured in overlay-ports, so "overlay-ports" values cannot be ".".
78+
"@
79+
80+
# Test that trying to declare overlay-ports as the same directory in a roundabout way fails
81+
$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-not-quite-dot"
82+
$canonicalManifestRoot = (Get-Item $manifestRoot).FullName
83+
$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot
84+
Throw-IfNotFailed
85+
Throw-IfNonContains -Actual $output -Expected @"
86+
The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured in overlay-ports.
87+
"@
88+
5389
# Test that removals can happen without the overlay triplets
54-
Remove-Item env:VCPKG_OVERLAY_PORTS
5590
Refresh-TestRoot
5691
Run-Vcpkg install another-vcpkg-empty-port:fancy-triplet `
5792
--overlay-ports=$PSScriptRoot/../e2e-projects/overlays-project-with-config/cli-overlays `

docs/testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ the line when someone complains!
77

88
## Running end to end (e2e) tests
99

10+
Before running the tests you must have installed the `Pester` module.
11+
This can be done by running `Install-Module -Name Pester -MinimumVersion 5.6.1 -MaximumVersion 5.99 -Force` in a PowerShell session.
1012
To run the e2e test run the following command:
1113
`pwsh azure-pipelines/end-to-end-tests.ps1`
1214
**Parameters**:
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

3-
#include <vcpkg/base/expected.h>
3+
#include <vcpkg/base/diagnostics.h>
4+
#include <vcpkg/base/optional.h>
45
#include <vcpkg/base/stringview.h>
56

67
#include <string>
@@ -10,21 +11,22 @@ namespace vcpkg
1011
namespace details
1112
{
1213
template<class F>
13-
void api_stable_format_cb(void* f, std::string& s, StringView sv)
14+
bool api_stable_format_cb(void* f, std::string& s, StringView sv)
1415
{
15-
(*(F*)(f))(s, sv);
16+
return (*(F*)(f))(s, sv);
1617
}
1718

18-
ExpectedL<std::string> api_stable_format_impl(StringView fmtstr,
19-
void (*cb)(void*, std::string&, StringView),
20-
void* data);
19+
Optional<std::string> api_stable_format_impl(DiagnosticContext& context,
20+
StringView fmtstr,
21+
bool (*cb)(void*, std::string&, StringView),
22+
void* data);
2123
}
2224

2325
// This function exists in order to provide an API-stable formatting function similar to `std::format()` that does
2426
// not depend on the feature set of fmt or the C++ standard library and thus can be contractual for user interfaces.
2527
template<class F>
26-
ExpectedL<std::string> api_stable_format(StringView fmtstr, F&& handler)
28+
Optional<std::string> api_stable_format(DiagnosticContext& context, StringView fmtstr, F&& handler)
2729
{
28-
return details::api_stable_format_impl(fmtstr, &details::api_stable_format_cb<F>, &handler);
30+
return details::api_stable_format_impl(context, fmtstr, &details::api_stable_format_cb<F>, &handler);
2931
}
3032
}

0 commit comments

Comments
 (0)