-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[vcpkg] Refactor end-to-end tests #15081
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||||||||||||||||
|
|
||||||||||||||||
| # Test that prohibiting backcompat features actually prohibits | ||||||||||||||||
| $backcompatFeaturePorts = @('vcpkg-uses-test-cmake', 'vcpkg-uses-vcpkg-common-functions') | ||||||||||||||||
| foreach ($backcompatFeaturePort in $backcompatFeaturePorts) { | ||||||||||||||||
| $succeedArgs = $commonArgs + @('install',$backcompatFeaturePort,'--no-binarycaching') | ||||||||||||||||
| $failArgs = $succeedArgs + @('--x-prohibit-backcompat-features') | ||||||||||||||||
| $CurrentTest = "Should fail: ./vcpkg $($failArgs -join ' ')" | ||||||||||||||||
| Write-Host $CurrentTest | ||||||||||||||||
| ./vcpkg @failArgs | ||||||||||||||||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| if ($LastExitCode -ne 0) { | ||||||||||||||||
| Write-Host "... failed (this is good!)" | ||||||||||||||||
| } else { | ||||||||||||||||
| throw $CurrentTest | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+11
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| # Install failed when prohibiting backcompat features, so it should succeed if we allow them | ||||||||||||||||
| $CurrentTest = "Should succeeed: ./vcpkg $($succeedArgs -join ' ')" | ||||||||||||||||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| Write-Host $CurrentTest | ||||||||||||||||
| ./vcpkg @succeedArgs | ||||||||||||||||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
| if ($LastExitCode -ne 0) { | ||||||||||||||||
| throw $CurrentTest | ||||||||||||||||
| } else { | ||||||||||||||||
| Write-Host "... succeeded." | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+21
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||
|
|
||
| # Test simple installation | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "rapidjson", "--binarycaching", "--x-binarysource=clear;files,$ArchiveRoot,write;nuget,$NuGetRoot,readwrite")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
|
|
||
| # Test simple removal | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("remove", "rapidjson")) | ||
| Throw-IfFailed | ||
| Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
|
|
||
| # Test restoring from files archive | ||
| Remove-Item -Recurse -Force $installRoot | ||
| Remove-Item -Recurse -Force $buildtreesRoot | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileNotExists "$buildtreesRoot/rapidjson/src" | ||
| Require-FileExists "$buildtreesRoot/detect_compiler" | ||
|
|
||
| # Test --no-binarycaching | ||
| Remove-Item -Recurse -Force $installRoot | ||
| Remove-Item -Recurse -Force $buildtreesRoot | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install","rapidjson","--no-binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileExists "$buildtreesRoot/rapidjson/src" | ||
| Require-FileExists "$buildtreesRoot/detect_compiler" | ||
|
|
||
| # Test --editable | ||
| Remove-Item -Recurse -Force $installRoot | ||
| Remove-Item -Recurse -Force $buildtreesRoot | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install","rapidjson","--editable","--x-binarysource=clear;files,$ArchiveRoot,read")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileExists "$buildtreesRoot/rapidjson/src" | ||
| Require-FileNotExists "$buildtreesRoot/detect_compiler" | ||
|
|
||
| # Test restoring from nuget | ||
| Remove-Item -Recurse -Force $installRoot | ||
| Remove-Item -Recurse -Force $buildtreesRoot | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "rapidjson", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileNotExists "$buildtreesRoot/rapidjson/src" | ||
|
|
||
| # Test four-phase flow | ||
| Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "rapidjson", "--dry-run", "--x-write-nuget-packages-config=$TestingRoot/packages.config")) | ||
| Throw-IfFailed | ||
| Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileNotExists "$buildtreesRoot/rapidjson/src" | ||
| Require-FileExists "$TestingRoot/packages.config" | ||
| if ($IsLinux -or $IsMacOS) { | ||
| mono $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot" | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else { | ||
| & $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot" | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| Throw-IfFailed | ||
| Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue | ||
| mkdir $NuGetRoot | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "rapidjson", "tinyxml", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,write")) | ||
| Throw-IfFailed | ||
| Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h" | ||
| Require-FileExists "$installRoot/$Triplet/include/tinyxml.h" | ||
| Require-FileNotExists "$buildtreesRoot/rapidjson/src" | ||
| Require-FileExists "$buildtreesRoot/tinyxml/src" | ||
| if ((Get-ChildItem $NuGetRoot -Filter '*.nupkg' | Measure-Object).Count -ne 1) { | ||
| throw "In '$CurrentTest': did not create exactly 1 NuGet package" | ||
| } | ||
|
|
||
| # Test export | ||
| $CurrentTest = 'Exporting' | ||
| Require-FileNotExists "$TestingRoot/vcpkg-export-output" | ||
| Require-FileNotExists "$TestingRoot/vcpkg-export.1.0.0.nupkg" | ||
| Require-FileNotExists "$TestingRoot/vcpkg-export-output.zip" | ||
| Run-Vcpkg -TestArgs ($commonArgs + @("export", "rapidjson", "tinyxml", "--nuget", "--nuget-id=vcpkg-export", "--nuget-version=1.0.0", "--output=vcpkg-export-output", "--raw", "--zip", "--output-dir=$TestingRoot")) | ||
| Require-FileExists "$TestingRoot/vcpkg-export-output" | ||
| Require-FileExists "$TestingRoot/vcpkg-export.1.0.0.nupkg" | ||
| Require-FileExists "$TestingRoot/vcpkg-export-output.zip" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||||||
|
|
||||||
| # Test bad command lines | ||||||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "zlib", "--vcpkg-rootttttt", "C:\")) | ||||||
| Throw-IfNotFailed | ||||||
|
|
||||||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "zlib", "--vcpkg-rootttttt=C:\")) | ||||||
| Throw-IfNotFailed | ||||||
|
|
||||||
| Run-Vcpkg -TestArgs ($commonArgs + @("install", "zlib", "--fast")) # NB: --fast is not a switch | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
best to choose something that'll never possibly be a switch |
||||||
| Throw-IfNotFailed | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||
|
|
||
| # Test vcpkg create | ||
| $CurrentTest = "create zlib" | ||
| Write-Host $CurrentTest | ||
| ./vcpkg --x-builtin-ports-root=$TestingRoot/ports create zlib https://github.com/madler/zlib/archive/v1.2.11.tar.gz zlib-1.2.11.tar.gz | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Throw-IfFailed | ||
|
|
||
| Require-FileExists "$TestingRoot/ports/zlib/portfile.cmake" | ||
| Require-FileExists "$TestingRoot/ports/zlib/vcpkg.json" | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||
| if (-not $IsLinux -and -not $IsMacOS) { | ||||||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||||||
|
|
||||||
| # Test msbuild props and targets | ||||||
| $CurrentTest = "zlib:x86-windows-static msbuild scripts\testing\integrate-install\..." | ||||||
| Write-Host $CurrentTest | ||||||
| ./vcpkg $commonArgs install zlib:x86-windows-static --x-binarysource=clear | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Throw-IfFailed | ||||||
| foreach ($project in @("VcpkgTriplet", "VcpkgTriplet2", "VcpkgUseStatic", "VcpkgUseStatic2")) { | ||||||
| $CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj" | ||||||
| ./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ " | ||||||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| Throw-IfFailed | ||||||
| Remove-Item -Recurse -Force $TestingRoot\int | ||||||
| Remove-Item -Recurse -Force $TestingRoot\out | ||||||
| } | ||||||
| $CurrentTest = "zlib:x86-windows msbuild scripts\testing\integrate-install\..." | ||||||
| Write-Host $CurrentTest | ||||||
| ./vcpkg $commonArgs install zlib:x86-windows --x-binarysource=clear | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Throw-IfFailed | ||||||
| foreach ($project in @("Project1", "NoProps")) { | ||||||
| $CurrentTest = "msbuild scripts\testing\integrate-install\$project.vcxproj" | ||||||
| Write-Host $CurrentTest | ||||||
| ./vcpkg $commonArgs env "msbuild scripts\testing\integrate-install\$project.vcxproj /p:VcpkgRoot=$TestingRoot /p:IntDir=$TestingRoot\int\ /p:OutDir=$TestingRoot\out\ " | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Throw-IfFailed | ||||||
| Remove-Item -Recurse -Force $TestingRoot\int | ||||||
| Remove-Item -Recurse -Force $TestingRoot\out | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| . $PSScriptRoot/../end-to-end-tests-prelude.ps1 | ||
|
|
||
| ##### Test spaces in the path | ||
| $CurrentTest = "zlib with spaces in path" | ||
| Write-Host $CurrentTest | ||
| ./vcpkg install zlib "--triplet" $Triplet ` | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "--no-binarycaching" ` | ||
| "--x-buildtrees-root=$TestingRoot/build Trees" ` | ||
| "--x-install-root=$TestingRoot/instalL ed" ` | ||
| "--x-packages-root=$TestingRoot/packaG es" | ||
| Throw-IfFailed | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| $TestingRoot = Join-Path $WorkingRoot 'testing' | ||
| $buildtreesRoot = Join-Path $TestingRoot 'buildtrees' | ||
| $installRoot = Join-Path $TestingRoot 'installed' | ||
| $packagesRoot = Join-Path $TestingRoot 'packages' | ||
| $NuGetRoot = Join-Path $TestingRoot 'nuget' | ||
| $NuGetRoot2 = Join-Path $TestingRoot 'nuget2' | ||
| $ArchiveRoot = Join-Path $TestingRoot 'archives' | ||
| $VersionFilesRoot = Join-Path $TestingRoot 'version-test' | ||
| $commonArgs = @( | ||
| "--triplet", | ||
| $Triplet, | ||
| "--x-buildtrees-root=$buildtreesRoot", | ||
| "--x-install-root=$installRoot", | ||
| "--x-packages-root=$packagesRoot", | ||
| "--overlay-ports=scripts/e2e_ports" | ||
| ) | ||
| $CurrentTest = 'unassigned' | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| function Refresh-TestRoot { | ||
| Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue | ||
| mkdir $TestingRoot | Out-Null | ||
| mkdir $NuGetRoot | Out-Null | ||
| } | ||
|
|
||
| function Require-FileExists { | ||
| [CmdletBinding()] | ||
| Param( | ||
| [string]$File | ||
| ) | ||
| if (-Not (Test-Path $File)) { | ||
| throw "'$CurrentTest' failed to create file '$File'" | ||
| } | ||
| } | ||
|
|
||
| function Require-FileNotExists { | ||
| [CmdletBinding()] | ||
| Param( | ||
| [string]$File | ||
| ) | ||
| if (Test-Path $File) { | ||
| throw "'$CurrentTest' should not have created file '$File'" | ||
| } | ||
| } | ||
|
|
||
| function Throw-IfFailed { | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "'$CurrentTest' had a step with a nonzero exit code" | ||
| } | ||
| } | ||
|
|
||
| function Throw-IfNotFailed { | ||
| if ($LASTEXITCODE -eq 0) { | ||
| throw "'$CurrentTest' had a step with an unexpectedly zero exit code" | ||
| } | ||
| } | ||
|
|
||
| function Run-Vcpkg { | ||
| param([string[]]$TestArgs) | ||
| $CurrentTest = "./vcpkg $($testArgs -join ' ')" | ||
| Write-Host $CurrentTest | ||
| ./vcpkg @testArgs | ||
ras0219 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| Refresh-TestRoot | ||
Uh oh!
There was an error while loading. Please reload this page.