Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commonize \r\n / \n handling in test cases. #1519

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@ if ($output -notmatch 'Trailing comma') {
# Check for msgAlreadyInstalled vs. msgAlreadyInstalledNotHead
$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" install vcpkg-internal-e2e-test-port3
Throw-IfFailed
if ($output -notmatch 'vcpkg-internal-e2e-test-port3:[^ ]+ is already installed') {
if (-not $output -contains @"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it is testing for completely different output; what am I missing here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I'm surprised it passes now. There is duplicate output here. In #1514 from which this change was extracted, I removed the duplicate output, and had to fix this test to look for the not removed of the two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this one to do Throw-IfNotContains and I reverted the other one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

The following packages are already installed:
vcpkg-internal-e2e-test-port3:
"@) {
throw 'Wrong already installed message'
}

$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" install vcpkg-internal-e2e-test-port3 --head
Throw-IfFailed
if ($output -notmatch 'vcpkg-internal-e2e-test-port3:[^ ]+ is already installed -- not building from HEAD') {
if (-not $output -contains @"
The following packages are already installed, but were requested at --head version. Their installed contents will not be changed. To get updated versions, remove these packages first:
vcpkg-internal-e2e-test-port3:
"@) {
throw 'Wrong already installed message for --head'
}

Refresh-TestRoot
$output = Run-VcpkgAndCaptureOutput @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-ports" install vcpkg-bad-spdx-license
Throw-IfFailed
$output = $output.Replace("`r`n", "`n")
$expected = @"
vcpkg.json: warning: $.license (an SPDX license expression): warning: Unknown license identifier 'BSD-new'. Known values are listed at https://spdx.org/licenses/
on expression: BSD-new
Expand Down
13 changes: 3 additions & 10 deletions azure-pipelines/end-to-end-tests-dir/ci-verify-versions.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
. "$PSScriptRoot/../end-to-end-tests-prelude.ps1"

Refresh-TestRoot

Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/ci-verify-versions-registry" "$TestingRoot/ci-verify-versions-registry"
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions init
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions add -A
Expand Down Expand Up @@ -160,17 +158,12 @@ Throw-IfNotFailed

function Sanitize() {
Param([string]$text)
$workTreeRegex = 'error: failed to execute:[^\r\n]+' # Git command line has an unpredictable PID inside
$text = $text.Replace('\', '/').Replace("`r`n", "`n").Trim()
$workTreeRegex = 'error: failed to execute:[^\n]+' # Git command line has an unpredictable PID inside
$text = $text.Replace('\', '/').Trim()
$text = [System.Text.RegularExpressions.Regex]::Replace($text, $workTreeRegex, '')
return $text
}

$expected = Sanitize $expected
$actual = Sanitize $actual
if ($actual -ne $expected) {
Set-Content -Value $expected -LiteralPath "$TestingRoot/expected.txt"
Set-Content -Value $actual -LiteralPath "$TestingRoot/actual.txt"
git diff --no-index -- "$TestingRoot/expected.txt" "$TestingRoot/actual.txt"
throw "Bad x-ci-verify-versions output."
}
Throw-IfNonEqual -Expected $expected -Actual $actual
16 changes: 8 additions & 8 deletions azure-pipelines/end-to-end-tests-dir/cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ error: expected the end of input parsing a package spec; this usually means the

"@

if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw 'Bad malformed port name output; it was: ' + $out
}
Expand All @@ -71,7 +71,7 @@ error: unknown binary provider type: valid providers are 'clear', 'default', 'nu

"@

if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw 'Bad malformed --binarysource output; it was: ' + $out
}
Expand All @@ -86,7 +86,7 @@ error: Invalid triplet name. Triplet names are all lowercase alphanumeric+hyphen
Built-in Triplets:
"@

if (-Not ($out.Replace("`r`n", "`n").StartsWith($expected)))
if (-Not ($out.StartsWith($expected)))
{
throw 'Bad malformed triplet output. It was: ' + $out
}
Expand All @@ -99,7 +99,7 @@ error: expected an explicit triplet
^

"@
if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw ('Bad error output: ' + $out)
}
Expand All @@ -112,7 +112,7 @@ error: expected an explicit triplet
^

"@
if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw ('Bad error output: ' + $out)
}
Expand All @@ -125,7 +125,7 @@ error: expected the end of input parsing a package spec; did you mean zlib[core]
^

"@
if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw ('Bad error output: ' + $out)
}
Expand All @@ -138,7 +138,7 @@ error: List of features is not allowed in this context
^

"@
if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw ('Bad error output: ' + $out)
}
Expand All @@ -151,7 +151,7 @@ error: Platform qualifier is not allowed in this context
^

"@
if (-Not ($out.Replace("`r`n", "`n").EndsWith($expected)))
if (-Not ($out.EndsWith($expected)))
{
throw ('Bad error output: ' + $out)
}
4 changes: 2 additions & 2 deletions azure-pipelines/end-to-end-tests-dir/env-passthrough.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ if (-not $IsLinux -and -not $IsMacOS) {
$env:_VCPKG_TEST_UNTRACKED = "b"

$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")
if ($x -ne "%_VCPKG_TEST_TRACKED% %_VCPKG_TEST_TRACKED2% %_VCPKG_TEST_UNTRACKED% %_VCPKG_TEST_UNTRACKED2%`n")
{
throw "env should have cleaned the environment ($x)"
}

$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")
if ($y -ne "a %_VCPKG_TEST_TRACKED2% b %_VCPKG_TEST_UNTRACKED2%`n")
{
throw "env should have kept the environment ($y)"
}
Expand Down
Loading
Loading