diff options
| author | ras0219 <robertallenschumacher@gmail.com> | 2020-07-01 11:36:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 11:36:09 -0700 |
| commit | 135f91de1eef9e906eb7a5bcf323f6eff9a2b5da (patch) | |
| tree | 71dfb029d57d3a205a8685bd357586148480d09c /scripts | |
| parent | 42f70a42766ff3da9c0464dd78f1eed0e8ac3789 (diff) | |
| download | vcpkg-135f91de1eef9e906eb7a5bcf323f6eff9a2b5da.tar.gz vcpkg-135f91de1eef9e906eb7a5bcf323f6eff9a2b5da.zip | |
[vcpkg] Implement --x-write-nuget-packages-config= setting for `install` and `x-set-installed` (#12138)
* [vcpkg] Implement --x-write-nuget-packages-config= setting for `install` and `x-set-installed`.
* [vcpkg] Add end-to-end testing suite for install, remove, and binary caching
* [vcpkg] Define `$TestingRoot in end-to-end-tests.ps1
* [vcpkg] Address CR comments
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/azure-pipelines/end-to-end-tests.ps1 | 134 | ||||
| -rw-r--r-- | scripts/azure-pipelines/windows/azure-pipelines.yml | 1 |
2 files changed, 135 insertions, 0 deletions
diff --git a/scripts/azure-pipelines/end-to-end-tests.ps1 b/scripts/azure-pipelines/end-to-end-tests.ps1 new file mode 100644 index 000000000..b0642df82 --- /dev/null +++ b/scripts/azure-pipelines/end-to-end-tests.ps1 @@ -0,0 +1,134 @@ +# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: MIT
+#
+<#
+.SYNOPSIS
+End-to-End tests for the vcpkg executable.
+
+.DESCRIPTION
+These tests cover the command line interface and broad functions of vcpkg, including `install`, `remove` and certain
+binary caching scenarios. They use the vcpkg executable in the current directory.
+
+.PARAMETER Triplet
+The triplet to use for testing purposes.
+
+.PARAMETER WorkingRoot
+The location used as scratch space for testing.
+
+#>
+
+[CmdletBinding()]
+Param(
+ [Parameter(Mandatory = $true)]
+ [ValidateNotNullOrEmpty()]
+ [string]$Triplet,
+ [Parameter(Mandatory = $true)]
+ [ValidateNotNullOrEmpty()]
+ [string]$WorkingRoot
+)
+
+$ErrorActionPreference = "Stop"
+
+$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'
+$commonArgs = @(
+ "--triplet",
+ $Triplet,
+ "--x-buildtrees-root=$buildtreesRoot",
+ "--x-install-root=$installRoot",
+ "--x-packages-root=$packagesRoot"
+)
+
+Remove-Item -Recurse -Force $TestingRoot -ErrorAction SilentlyContinue
+mkdir $TestingRoot
+mkdir $NuGetRoot
+
+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'"
+ }
+}
+
+# Test simple installation
+$args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,write;nuget,$NuGetRoot,upload")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Write-Host $CurrentTest
+./vcpkg @args
+
+Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
+
+# Test simple removal
+$args = $commonArgs + @("remove", "rapidjson")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Write-Host $CurrentTest
+./vcpkg @args
+
+Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
+
+# Test restoring from files archive
+$args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Remove-Item -Recurse -Force $installRoot
+Remove-Item -Recurse -Force $buildtreesRoot
+Write-Host $CurrentTest
+./vcpkg @args
+
+Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
+Require-FileNotExists "$buildtreesRoot/rapidjson/src"
+
+# Test restoring from nuget
+$args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;nuget,$NuGetRoot")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Remove-Item -Recurse -Force $installRoot
+Remove-Item -Recurse -Force $buildtreesRoot
+Write-Host $CurrentTest
+./vcpkg @args
+
+Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
+Require-FileNotExists "$buildtreesRoot/rapidjson/src"
+
+# Test four-phase flow
+$args = $commonArgs + @("install","rapidjson","--dry-run","--x-write-nuget-packages-config=$TestingRoot/packages.config")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue
+Write-Host $CurrentTest
+./vcpkg @args
+Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
+Require-FileNotExists "$buildtreesRoot/rapidjson/src"
+Require-FileExists "$TestingRoot/packages.config"
+
+& $(./vcpkg fetch nuget) restore $TestingRoot/packages.config -OutputDirectory "$NuGetRoot2" -Source "$NuGetRoot"
+
+Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
+mkdir $NuGetRoot
+
+$args = $commonArgs + @("install","rapidjson","tinyxml","--binarycaching","--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,upload")
+$CurrentTest = "./vcpkg $($args -join ' ')"
+Write-Host $CurrentTest
+./vcpkg @args
+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"
+}
diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index 69ea089d6..a20ee23bb 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -42,6 +42,7 @@ jobs: cmake.exe -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DVCPKG_DEVELOPMENT_WARNINGS=ON -DVCPKG_WARNINGS_AS_ERRORS=ON -DVCPKG_BUILD_FUZZING=ON -B build.x86.debug -S toolsrc
ninja.exe -C build.x86.debug
build.x86.debug\vcpkg-test.exe
+ powershell.exe -NoProfile -ExecutionPolicy Bypass "scripts\azure-pipelines\end-to-end-tests.ps1 -WorkingRoot \"%cd%\testing\" -triplet x86-windows"
failOnStderr: true
- task: PowerShell@2
displayName: '*** Test Modified Ports and Prepare Test Logs ***'
|
