|
1 | 1 | . "$PSScriptRoot/../end-to-end-tests-prelude.ps1"
|
2 | 2 |
|
3 |
| -git clone $VcpkgRoot "$TestingRoot/temp-repo" --local |
4 |
| -try |
5 |
| -{ |
6 |
| - $env:VCPKG_ROOT = "$TestingRoot/temp-repo" |
7 |
| - git -C "$TestingRoot/temp-repo" switch -d e1934f4a2a0c58bb75099d89ed980832379907fa # vcpkg-cmake @ 2022-12-22 |
8 |
| - Copy-Item "$VcpkgRoot/scripts/vcpkgTools.xml" "$TestingRoot/temp-repo/scripts/vcpkgTools.xml" -Force |
9 |
| - $output = Run-VcpkgAndCaptureOutput install vcpkg-cmake |
10 |
| - Throw-IfFailed |
11 |
| - if (-Not ($output -match 'vcpkg-cmake:[^ ]+@2022-12-22')) |
12 |
| - { |
13 |
| - throw 'Unexpected vcpkg-cmake install' |
14 |
| - } |
15 |
| - |
16 |
| - git -C "$TestingRoot/temp-repo" checkout -- 'scripts/vcpkgTools.xml' |
17 |
| - git -C "$TestingRoot/temp-repo" switch -d f6a5d4e8eb7476b8d7fc12a56dff300c1c986131 # vcpkg-cmake @ 2023-05-04 |
18 |
| - Copy-Item "$VcpkgRoot/scripts/vcpkgTools.xml" "$TestingRoot/temp-repo/scripts/vcpkgTools.xml" -Force |
19 |
| - $output = Run-VcpkgAndCaptureOutput upgrade |
20 |
| - Throw-IfNotFailed |
21 |
| - if (-Not ($output -match 'If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.')) |
22 |
| - { |
23 |
| - throw "Upgrade didn't handle dry-run correctly" |
24 |
| - } |
25 |
| - |
26 |
| - if (-Not ($output -match '\* vcpkg-cmake:[^ ]+@2023-05-04')) |
27 |
| - { |
28 |
| - throw "Upgrade didn't choose expected version" |
29 |
| - } |
30 |
| - |
31 |
| - $output = Run-VcpkgAndCaptureOutput upgrade --no-dry-run |
32 |
| - Throw-IfFailed |
33 |
| - if (-Not ($output -match '\* vcpkg-cmake:[^ ]+@2023-05-04')) |
34 |
| - { |
35 |
| - throw "Upgrade didn't choose expected version" |
36 |
| - } |
37 |
| - |
38 |
| - if (-Not ($output -match 'vcpkg-cmake:[^:]+: REMOVED:')) |
39 |
| - { |
40 |
| - throw "Upgrade didn't remove" |
41 |
| - } |
42 |
| - |
43 |
| - if (-Not ($output -match 'vcpkg-cmake:[^:]+: SUCCEEDED:')) |
44 |
| - { |
45 |
| - throw "Upgrade didn't install" |
46 |
| - } |
47 |
| -} |
48 |
| -finally |
49 |
| -{ |
50 |
| - $env:VCPKG_ROOT = $VcpkgRoot |
| 3 | +Refresh-TestRoot |
| 4 | + |
| 5 | +$portsRoot = Join-Path $TestingRoot 'ports' |
| 6 | +New-Item -ItemType Directory -Force $portsRoot | Out-Null |
| 7 | +Set-EmptyTestPort -Name 'upgrade-test-port' -Version '0' -PortsRoot $portsRoot |
| 8 | +$output = Run-VcpkgAndCaptureOutput install upgrade-test-port "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 9 | +Throw-IfFailed |
| 10 | +if (-Not ($output -match 'upgrade-test-port:[^ ]+@0')) |
| 11 | +{ |
| 12 | + throw 'Unexpected upgrade-test-port install' |
| 13 | +} |
| 14 | + |
| 15 | +Set-EmptyTestPort -Name 'upgrade-test-port' -Version '1' -PortsRoot $portsRoot |
| 16 | +$output = Run-VcpkgAndCaptureOutput upgrade "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 17 | +Throw-IfNotFailed |
| 18 | +if (-Not ($output -match 'If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.')) |
| 19 | +{ |
| 20 | + throw "Upgrade didn't handle dry-run correctly" |
| 21 | +} |
| 22 | + |
| 23 | +if (-Not ($output -match '\* upgrade-test-port:[^ ]+@1')) |
| 24 | +{ |
| 25 | + throw "Upgrade didn't choose expected version" |
| 26 | +} |
| 27 | + |
| 28 | +$output = Run-VcpkgAndCaptureOutput upgrade --no-dry-run "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 29 | +Throw-IfFailed |
| 30 | +if (-Not ($output -match '\* upgrade-test-port:[^ ]+@1')) |
| 31 | +{ |
| 32 | + throw "Upgrade didn't choose expected version" |
| 33 | +} |
| 34 | + |
| 35 | +if (-Not ($output -match 'upgrade-test-port:[^:]+: REMOVED:')) |
| 36 | +{ |
| 37 | + throw "Upgrade didn't remove" |
| 38 | +} |
| 39 | + |
| 40 | +if (-Not ($output -match 'upgrade-test-port:[^:]+: SUCCEEDED:')) |
| 41 | +{ |
| 42 | + throw "Upgrade didn't install" |
| 43 | +} |
| 44 | + |
| 45 | +# Also test explicitly providing the name |
| 46 | + |
| 47 | +Set-EmptyTestPort -Name 'upgrade-test-port' -Version '2' -PortsRoot $portsRoot |
| 48 | +$output = Run-VcpkgAndCaptureOutput upgrade upgrade-test-port "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 49 | +Throw-IfNotFailed |
| 50 | +if (-Not ($output -match 'If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.')) |
| 51 | +{ |
| 52 | + throw "Upgrade didn't handle dry-run correctly" |
| 53 | +} |
| 54 | + |
| 55 | +if (-Not ($output -match '\* upgrade-test-port:[^ ]+@2')) |
| 56 | +{ |
| 57 | + throw "Upgrade didn't choose expected version" |
| 58 | +} |
| 59 | + |
| 60 | +$output = Run-VcpkgAndCaptureOutput upgrade upgrade-test-port --no-dry-run "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 61 | +Throw-IfFailed |
| 62 | +if (-Not ($output -match '\* upgrade-test-port:[^ ]+@2')) |
| 63 | +{ |
| 64 | + throw "Upgrade didn't choose expected version" |
| 65 | +} |
| 66 | + |
| 67 | +if (-Not ($output -match 'upgrade-test-port:[^:]+: REMOVED:')) |
| 68 | +{ |
| 69 | + throw "Upgrade didn't remove" |
| 70 | +} |
| 71 | + |
| 72 | +if (-Not ($output -match 'upgrade-test-port:[^:]+: SUCCEEDED:')) |
| 73 | +{ |
| 74 | + throw "Upgrade didn't install" |
| 75 | +} |
| 76 | + |
| 77 | +# Also test providing a nonexistent name |
| 78 | + |
| 79 | +$output = Run-VcpkgAndCaptureStdErr upgrade nonexistent "--x-builtin-ports-root=$portsRoot" @commonArgs |
| 80 | +Throw-IfNotFailed |
| 81 | +if ($output -match 'internal error:') |
| 82 | +{ |
| 83 | + throw "Upgrade with a nonexistent name crashed" |
51 | 84 | }
|
0 commit comments