e2e tests: undouble output (#801)
* e2e tests: undouble output * Fix windows ci
This commit is contained in:
Родитель
615734526b
Коммит
08179bb991
|
@ -66,7 +66,7 @@ $privatePrefixesToTest = @(
|
|||
function testPrefixes($toTest, $commands) {
|
||||
$toTest | % {
|
||||
$expected = getOptionsForPrefix $_ $commands
|
||||
$found = Run-Vcpkg autocomplete $_
|
||||
$found = Run-VcpkgAndCaptureOutput autocomplete $_
|
||||
Throw-IfFailed
|
||||
if (-not $expected -eq $found) {
|
||||
Write-Host "unexpected result from vcpkg autocomplete:
|
||||
|
|
|
@ -67,7 +67,7 @@ if(-Not $IsLinux -and -Not $IsMacOS) {
|
|||
if ($IsLinux -or $IsMacOS) {
|
||||
mono $(Run-Vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
} else {
|
||||
& $(Run-Vcpkg @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
& $(Run-VcpkgAndCaptureOutput @fetchNuGetArgs) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
|
||||
}
|
||||
Throw-IfFailed
|
||||
Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
$CurrentTest = "Build Command"
|
||||
|
||||
# Test that the build command fails if dependencies are missing
|
||||
$out = Run-Vcpkg -TestArgs ($commonArgs + @("build","vcpkg-hello-world-1","--host-triplet",$Triplet))
|
||||
$out = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("build","vcpkg-hello-world-1","--host-triplet",$Triplet))
|
||||
Throw-IfNotFailed
|
||||
if ($out -notmatch "The build command requires all dependencies to be already installed\.")
|
||||
{
|
||||
$out
|
||||
throw "Expected to fail due to missing dependencies"
|
||||
}
|
||||
|
||||
|
@ -22,10 +21,9 @@ Throw-IfFailed
|
|||
# Regression test https://github.com/microsoft/vcpkg/issues/13933
|
||||
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1","--host-triplet",$Triplet))
|
||||
Throw-IfFailed
|
||||
$out = Run-Vcpkg -TestArgs ($commonArgs + @("build","vcpkg-hello-world-1","--host-triplet",$Triplet))
|
||||
$out = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("build","vcpkg-hello-world-1","--host-triplet",$Triplet))
|
||||
Throw-IfNotFailed
|
||||
if ($out -notmatch "is already installed; please remove")
|
||||
{
|
||||
$out
|
||||
throw "Expected to fail due to already being installed"
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ $CurrentTest = "Build Test Ports"
|
|||
Run-Vcpkg @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports" install vcpkg-internal-e2e-test-port3
|
||||
Throw-IfFailed
|
||||
|
||||
$output = Run-Vcpkg @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/vcpkg-internal-e2e-test-port2" install vcpkg-internal-e2e-test-port2
|
||||
$output
|
||||
$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/vcpkg-internal-e2e-test-port2" install vcpkg-internal-e2e-test-port2
|
||||
Throw-IfFailed
|
||||
if ($output -match 'vcpkg-internal-e2e-test-port3') {
|
||||
throw "Should not emit messages about -port3 while checking -port2"
|
||||
|
@ -21,13 +20,13 @@ if ($IsWindows) {
|
|||
Throw-IfFailed
|
||||
}
|
||||
|
||||
$output = Run-Vcpkg @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/overlays" install broken-no-name
|
||||
$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/overlays" install broken-no-name
|
||||
Throw-IfNotFailed
|
||||
if (-not $output -match 'missing field') {
|
||||
throw 'Did not detect missing field'
|
||||
}
|
||||
|
||||
$output = Run-Vcpkg @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/overlays" install broken-no-version
|
||||
$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e_ports/overlays" install broken-no-version
|
||||
Throw-IfNotFailed
|
||||
if (-not $output -match 'missing field') {
|
||||
throw 'Did not detect missing field'
|
||||
|
|
|
@ -24,8 +24,7 @@ $commonArgs = @(
|
|||
New-Item -ItemType Directory -Force $bundle | Out-Null
|
||||
New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
|
||||
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
$b = @{
|
||||
|
@ -52,8 +51,7 @@ New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
|
|||
readonly = $True
|
||||
} | ConvertTo-JSON | out-file -enc ascii $bundle/vcpkg-bundle.json | Out-Null
|
||||
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
|
||||
|
@ -86,8 +84,7 @@ New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
|
|||
version = "0"
|
||||
} | ConvertTo-JSON | out-file -enc ascii $manifestdir/vcpkg.json | Out-Null
|
||||
|
||||
$a = Run-Vcpkg z-print-config --x-manifest-root=$manifestdir @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config --x-manifest-root=$manifestdir @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
|
||||
|
@ -124,13 +121,12 @@ New-Item -ItemType File -Force $bundle/.vcpkg-root | Out-Null
|
|||
dependencies = @("rapidjson")
|
||||
} | ConvertTo-JSON | out-file -enc ascii $manifestdir/vcpkg.json | Out-Null
|
||||
|
||||
$a = Run-Vcpkg z-print-config `
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config `
|
||||
@commonArgs `
|
||||
--x-manifest-root=$manifestdir `
|
||||
--x-buildtrees-root=$buildtreesRoot `
|
||||
--x-install-root=$installRoot `
|
||||
--x-packages-root=$packagesRoot
|
||||
$a
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
|
||||
|
@ -223,8 +219,7 @@ $env:VCPKG_NO_CI="1"
|
|||
$env:TF_BUILD="1"
|
||||
$env:CI="1"
|
||||
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
if ($a[$detected_ci_key] -ne 'VCPKG_NO_CI') {
|
||||
|
@ -232,8 +227,7 @@ if ($a[$detected_ci_key] -ne 'VCPKG_NO_CI') {
|
|||
}
|
||||
|
||||
Remove-Item env:VCPKG_NO_CI
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
if ($a[$detected_ci_key] -ne 'Azure_Pipelines') {
|
||||
|
@ -241,8 +235,7 @@ if ($a[$detected_ci_key] -ne 'Azure_Pipelines') {
|
|||
}
|
||||
|
||||
Remove-Item env:TF_BUILD
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
if ($a[$detected_ci_key] -ne 'Generic') {
|
||||
|
@ -250,8 +243,7 @@ if ($a[$detected_ci_key] -ne 'Generic') {
|
|||
}
|
||||
|
||||
Remove-Item env:CI
|
||||
$a = Run-Vcpkg z-print-config @commonArgs
|
||||
$a
|
||||
$a = Run-VcpkgAndCaptureOutput z-print-config @commonArgs
|
||||
Throw-IfFailed
|
||||
$a = $($a | ConvertFrom-JSON -AsHashtable)
|
||||
if ($a[$detected_ci_key] -ne $null) {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
|
||||
|
||||
# Not a number
|
||||
$out = Run-Vcpkg @commonArgs install classic-versions-b
|
||||
$out = Run-VcpkgAndCaptureOutput @commonArgs install classic-versions-b
|
||||
Throw-IfNotFailed
|
||||
if ($out -notmatch ".*warning:.*dependency classic-versions-a.*at least version 2.*is currently 1.*")
|
||||
{
|
||||
$out
|
||||
throw "Expected to fail and print warning about mismatched versions"
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ function Test-MetricsEnabled() {
|
|||
$actualArgs += $TestArgs
|
||||
}
|
||||
|
||||
$vcpkgOutput = Run-Vcpkg $actualArgs
|
||||
$vcpkgOutput = Run-VcpkgAndCaptureOutput $actualArgs
|
||||
if ($vcpkgOutput.Contains($metricsAreDisabledMessage)) {
|
||||
Write-Host 'Metrics are disabled'
|
||||
return $false
|
||||
|
@ -42,7 +42,7 @@ try {
|
|||
}
|
||||
|
||||
# Also test that you get no message without --sendmetrics
|
||||
$vcpkgOutput = Run-Vcpkg list
|
||||
$vcpkgOutput = Run-VcpkgAndCaptureOutput list
|
||||
if ($vcpkgOutput.Contains($metricsAreDisabledMessage)) {
|
||||
throw "Disabled metrics emit message even without --sendmetrics"
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ if (-not $IsLinux -and -not $IsMacOS) {
|
|||
$env:_VCPKG_TEST_TRACKED = "a"
|
||||
$env:_VCPKG_TEST_UNTRACKED = "b"
|
||||
|
||||
$x = Run-Vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
$x = Run-VcpkgAndCaptureOutput "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
if ($x -ne "%_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%`r`n")
|
||||
{
|
||||
throw "env should have cleaned the environment ($x)"
|
||||
}
|
||||
|
||||
$y = Run-Vcpkg "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env --triplet passthrough "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
$y = Run-VcpkgAndCaptureOutput "--overlay-triplets=$PSScriptRoot/../e2e_ports/env-passthrough" env --triplet passthrough "echo %_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%"
|
||||
if ($y -ne "a %_VCPKG_TEST_TRACKED2% b %_VCPKG_TEST_UNTRACKED2%`r`n")
|
||||
{
|
||||
throw "env should have kept the environment ($y)"
|
||||
|
|
|
@ -92,7 +92,7 @@ if (-not $IsMacOS -and -not $IsLinux) {
|
|||
Require-FileNotExists "$TestingRoot/down loads/tools/ninja-1.10.2-windows/ninja.exe"
|
||||
|
||||
Remove-Item env:VCPKG_FORCE_SYSTEM_BINARIES
|
||||
$out = Run-Vcpkg -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot", "--x-stderr-status"))
|
||||
$out = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @("fetch", "ninja", "--vcpkg-root=$TestingRoot", "--x-stderr-status"))
|
||||
Throw-IfFailed
|
||||
& $out --version
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
|
|
|
@ -6,7 +6,7 @@ $manifestPath = Join-Path $manifestDir 'vcpkg.json'
|
|||
$configurationPath = Join-Path $manifestDir 'vcpkg-configuration.json'
|
||||
|
||||
Push-Location $manifestDir
|
||||
$result = Run-Vcpkg new
|
||||
$result = Run-VcpkgAndCaptureOutput new
|
||||
Pop-Location
|
||||
Throw-IfNotFailed
|
||||
if (-not $result.Contains('--application')) {
|
||||
|
@ -31,7 +31,7 @@ if ($expected -ne $actual) {
|
|||
}
|
||||
|
||||
Push-Location $manifestDir
|
||||
$result = Run-Vcpkg new --application
|
||||
$result = Run-VcpkgAndCaptureOutput new --application
|
||||
Pop-Location
|
||||
Throw-IfNotFailed
|
||||
if (-not $result.Contains('A manifest is already present at')) {
|
||||
|
@ -40,7 +40,7 @@ if (-not $result.Contains('A manifest is already present at')) {
|
|||
|
||||
Remove-Item $manifestPath
|
||||
Push-Location $manifestDir
|
||||
$result = Run-Vcpkg new --application
|
||||
$result = Run-VcpkgAndCaptureOutput new --application
|
||||
Pop-Location
|
||||
Throw-IfNotFailed
|
||||
if (-not $result.Contains('Creating a manifest would overwrite a vcpkg-configuration.json')) {
|
||||
|
|
|
@ -4,7 +4,7 @@ $CurrentTest = "VCPKG_ROOT"
|
|||
|
||||
$targetMessage = 'ignoring mismatched VCPKG_ROOT environment value'
|
||||
|
||||
$defaultOutput = Run-Vcpkg -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port'))
|
||||
$defaultOutput = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port'))
|
||||
Throw-IfFailed
|
||||
if ($defaultOutput.Contains($targetMessage)) {
|
||||
throw 'Expected no warning about VCPKG_ROOT when using the environment variable.'
|
||||
|
@ -14,21 +14,20 @@ $actualVcpkgRoot = $env:VCPKG_ROOT
|
|||
|
||||
pushd $actualVcpkgRoot
|
||||
try {
|
||||
$samePathOutput = Run-Vcpkg -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port'))
|
||||
$samePathOutput = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port'))
|
||||
Throw-IfFailed
|
||||
if ($samePathOutput.Contains($targetMessage)) {
|
||||
throw 'Expected no warning about VCPKG_ROOT when the detected path is the same as the configured path.'
|
||||
}
|
||||
|
||||
$env:VCPKG_ROOT = Join-Path $actualVcpkgRoot 'ports' # any existing directory that isn't the detected root
|
||||
$differentPathOutput = Run-Vcpkg -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port', '--debug'))
|
||||
$differentPathOutput = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port', '--debug'))
|
||||
Throw-IfFailed
|
||||
if (-not ($differentPathOutput.Contains($targetMessage))) {
|
||||
throw 'Expected a warning about VCPKG_ROOT differing when the detected path differs from the configured path.'
|
||||
}
|
||||
|
||||
$setWithArgOutput = Run-Vcpkg -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port', '--vcpkg-root', $actualVcpkgRoot, '--debug'))
|
||||
echo $setWithArgOutput
|
||||
$setWithArgOutput = Run-VcpkgAndCaptureOutput -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port', '--vcpkg-root', $actualVcpkgRoot, '--debug'))
|
||||
Throw-IfFailed
|
||||
if ($setWithArgOutput.Contains($targetMessage)) {
|
||||
throw 'Expected no warning about VCPKG_ROOT when the path is configured with a command line argument.'
|
||||
|
|
|
@ -54,7 +54,7 @@ Throw-IfFailed
|
|||
|
||||
$CurrentTest = "x-add-version fish (must fail)"
|
||||
# Discrepancy between local SHA and SHA in fish.json. Requires --overwrite-version.
|
||||
$out = Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish
|
||||
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish
|
||||
Throw-IfNotFailed
|
||||
$CurrentTest = "x-add-version fish --overwrite-version"
|
||||
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish --overwrite-version --skip-version-format-check
|
||||
|
@ -69,22 +69,20 @@ Run-Vcpkg @portsRedirectArgsIncomplete x-ci-verify-versions --verbose
|
|||
Throw-IfFailed
|
||||
|
||||
$CurrentTest = "default baseline"
|
||||
$out = Run-Vcpkg @commonArgs "--feature-flags=versions" install --x-manifest-root=$versionFilesPath/default-baseline-1
|
||||
$out = Run-VcpkgAndCaptureOutput @commonArgs "--feature-flags=versions" install --x-manifest-root=$versionFilesPath/default-baseline-1
|
||||
Throw-IfNotFailed
|
||||
if ($out -notmatch ".*error: while checking out baseline\.*")
|
||||
{
|
||||
$out
|
||||
throw "Expected to fail due to missing baseline"
|
||||
}
|
||||
|
||||
$CurrentTest = "mismatched version database"
|
||||
$out = Run-Vcpkg @commonArgs "--feature-flags=versions" install --x-manifest-root="$PSScriptRoot/../e2e_ports/mismatched-version-database"
|
||||
$out = Run-VcpkgAndCaptureOutput @commonArgs "--feature-flags=versions" install --x-manifest-root="$PSScriptRoot/../e2e_ports/mismatched-version-database"
|
||||
Throw-IfNotFailed
|
||||
if (($out -notmatch ".*error: Failed to load port because versions are inconsistent*") -or
|
||||
($out -notmatch ".*version database indicates that it should be arrow@6.0.0.20210925#4.*") -or
|
||||
($out -notmatch ".*contains the version arrow@6.0.0.20210925.*"))
|
||||
{
|
||||
$out
|
||||
throw "Expected to fail due to mismatched versions between portfile and the version database"
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ function Write-Trace ([string]$text) {
|
|||
Write-Host (@($MyInvocation.ScriptName, ":", $MyInvocation.ScriptLineNumber, ": ", $text) -join "")
|
||||
}
|
||||
|
||||
function Run-Vcpkg {
|
||||
function Run-VcpkgAndCaptureOutput {
|
||||
Param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Switch]$EndToEndTestSilent,
|
||||
|
@ -106,4 +106,15 @@ function Run-Vcpkg {
|
|||
$result
|
||||
}
|
||||
|
||||
function Run-Vcpkg {
|
||||
Param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Switch]$EndToEndTestSilent,
|
||||
|
||||
[Parameter(ValueFromRemainingArguments)]
|
||||
[string[]]$TestArgs
|
||||
)
|
||||
Run-VcpkgAndCaptureOutput -EndToEndTestSilent:$EndToEndTestSilent @TestArgs | Out-Null
|
||||
}
|
||||
|
||||
Refresh-TestRoot
|
||||
|
|
Загрузка…
Ссылка в новой задаче