Skip to content

Commit cfecb21

Browse files
committed
Fix tests and update OneBranch pipeline
PowerShell 7.5 was released so the update test needed its usual fix. Ironically, OneBranch now uses 7.4 so we can rely on PSResourceGet existing.
1 parent f9ad474 commit cfecb21

File tree

3 files changed

+52
-44
lines changed

3 files changed

+52
-44
lines changed

.pipelines/vscode-powershell-Official.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ extends:
107107
$manifest = Test-ModuleManifest $(Build.SourcesDirectory)/modules/PowerShellEditorServices/PowerShellEditorServices.psd1
108108
Write-Host Using PowerShellEditorServices v$($manifest.Version)
109109
displayName: PowerShellEditorServices version
110-
- pwsh: |
111-
Register-PSRepository -Name CFS -SourceLocation "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v2" -InstallationPolicy Trusted
112-
Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet
113-
./tools/installPSResources.ps1 -PSRepository CFS
110+
- pwsh: ./tools/installPSResources.ps1 -PSRepository CFS
114111
displayName: Install PSResources
115112
- pwsh: Invoke-Build Build -Configuration $(BuildConfiguration)
116113
displayName: Build

test/features/UpdatePowerShell.test.ts

+38-38
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ describe("UpdatePowerShell feature", function () {
2828
it("Won't check if 'promptToUpdatePowerShell' is false", function () {
2929
settings.promptToUpdatePowerShell = false;
3030
const version: IPowerShellVersionDetails = {
31-
"version": "7.3.0",
32-
"edition": "Core",
33-
"commit": "7.3.0",
34-
"architecture": "X64"
31+
version: "7.3.0",
32+
edition: "Core",
33+
commit: "7.3.0",
34+
architecture: "X64",
3535
};
3636
const updater = new UpdatePowerShell(settings, testLogger, version);
3737
// @ts-expect-error method is private.
@@ -40,10 +40,10 @@ describe("UpdatePowerShell feature", function () {
4040

4141
it("Won't check for Windows PowerShell", function () {
4242
const version: IPowerShellVersionDetails = {
43-
"version": "5.1.22621",
44-
"edition": "Desktop",
45-
"commit": "5.1.22621",
46-
"architecture": "X64"
43+
version: "5.1.22621",
44+
edition: "Desktop",
45+
commit: "5.1.22621",
46+
architecture: "X64",
4747
};
4848
const updater = new UpdatePowerShell(settings, testLogger, version);
4949
// @ts-expect-error method is private.
@@ -52,10 +52,10 @@ describe("UpdatePowerShell feature", function () {
5252

5353
it("Won't check for a development build of PowerShell", function () {
5454
const version: IPowerShellVersionDetails = {
55-
"version": "7.3.0-preview.3",
56-
"edition": "Core",
57-
"commit": "7.3.0-preview.3-508-g07175ae0ff8eb7306fe0b0fc7d19bdef4fbf2d67",
58-
"architecture": "Arm64"
55+
version: "7.3.0-preview.3",
56+
edition: "Core",
57+
commit: "7.3.0-preview.3-508-g07175ae0ff8eb7306fe0b0fc7d19bdef4fbf2d67",
58+
architecture: "Arm64",
5959
};
6060
const updater = new UpdatePowerShell(settings, testLogger, version);
6161
// @ts-expect-error method is private.
@@ -64,10 +64,10 @@ describe("UpdatePowerShell feature", function () {
6464

6565
it("Won't check for a daily build of PowerShell", function () {
6666
const version: IPowerShellVersionDetails = {
67-
"version": "7.3.0-daily20221206.1",
68-
"edition": "Core",
69-
"commit": "7.3.0-daily20221206.1",
70-
"architecture": "Arm64"
67+
version: "7.3.0-daily20221206.1",
68+
edition: "Core",
69+
commit: "7.3.0-daily20221206.1",
70+
architecture: "Arm64",
7171
};
7272
const updater = new UpdatePowerShell(settings, testLogger, version);
7373
// @ts-expect-error method is private.
@@ -77,22 +77,22 @@ describe("UpdatePowerShell feature", function () {
7777
it("Won't check if POWERSHELL_UPDATECHECK is 'Off'", function () {
7878
process.env.POWERSHELL_UPDATECHECK = "Off";
7979
const version: IPowerShellVersionDetails = {
80-
"version": "7.3.0",
81-
"edition": "Core",
82-
"commit": "7.3.0",
83-
"architecture": "X64"
80+
version: "7.3.0",
81+
edition: "Core",
82+
commit: "7.3.0",
83+
architecture: "X64",
8484
};
8585
const updater = new UpdatePowerShell(settings, testLogger, version);
8686
// @ts-expect-error method is private.
8787
assert(!updater.shouldCheckForUpdate());
8888
});
8989

90-
it ("Should otherwise check to update PowerShell", function () {
90+
it("Should otherwise check to update PowerShell", function () {
9191
const version: IPowerShellVersionDetails = {
92-
"version": "7.3.0",
93-
"edition": "Core",
94-
"commit": "7.3.0",
95-
"architecture": "X64"
92+
version: "7.3.0",
93+
edition: "Core",
94+
commit: "7.3.0",
95+
architecture: "X64",
9696
};
9797
const updater = new UpdatePowerShell(settings, testLogger, version);
9898
// @ts-expect-error method is private.
@@ -101,34 +101,34 @@ describe("UpdatePowerShell feature", function () {
101101
});
102102

103103
describe("Which version it gets", function () {
104-
it("Would update to LTS", async function() {
104+
it("Would update to LTS", async function () {
105105
process.env.POWERSHELL_UPDATECHECK = "LTS";
106106
const version: IPowerShellVersionDetails = {
107-
"version": "7.0.0",
108-
"edition": "Core",
109-
"commit": "7.0.0",
110-
"architecture": "X64"
107+
version: "7.2.0",
108+
edition: "Core",
109+
commit: "7.2.0",
110+
architecture: "X64",
111111
};
112112
const updater = new UpdatePowerShell(settings, testLogger, version);
113113
// @ts-expect-error method is private.
114-
const tag: string = await updater.maybeGetNewRelease() ?? "";
114+
const tag: string = (await updater.maybeGetNewRelease()) ?? "";
115115
// NOTE: This will need to be updated each time an LTS is released.
116116
// Also sometimes the prior LTS is more recently updated than the latest LTS.
117-
assert(tag.startsWith("v7.4") || tag.startsWith("v7.2"));
117+
assert(tag.startsWith("v7.4"));
118118
});
119119

120-
it("Would update to stable", async function() {
120+
it("Would update to stable", async function () {
121121
const version: IPowerShellVersionDetails = {
122-
"version": "7.3.0",
123-
"edition": "Core",
124-
"commit": "7.3.0",
125-
"architecture": "X64"
122+
version: "7.3.0",
123+
edition: "Core",
124+
commit: "7.3.0",
125+
architecture: "X64",
126126
};
127127
const updater = new UpdatePowerShell(settings, testLogger, version);
128128
// @ts-expect-error method is private.
129129
const tag: string | undefined = await updater.maybeGetNewRelease();
130130
// NOTE: This will need to be updated each new major stable.
131-
assert(tag?.startsWith("v7.4"));
131+
assert(tag?.startsWith("v7.5"));
132132
});
133133
});
134134
});

tools/installPSResources.ps1

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,16 @@ if ($PSRepository -eq "CFS" -and -not (Get-PSResourceRepository -Name CFS -Error
99
Register-PSResourceRepository -Name CFS -Uri "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json"
1010
}
1111

12-
Install-PSResource -Repository $PSRepository -TrustRepository -Name InvokeBuild
13-
Install-PSResource -Repository $PSRepository -TrustRepository -Name platyPS
12+
# NOTE: Due to a bug in Install-PSResource with upstream feeds, we have to
13+
# request an exact version. Otherwise, if a newer version is available in the
14+
# upstream feed, it will fail to install any version at all.
15+
Install-PSResource -Verbose -TrustRepository -RequiredResource @{
16+
InvokeBuild = @{
17+
version = "5.12.1"
18+
repository = $PSRepository
19+
}
20+
platyPS = @{
21+
version = "0.14.2"
22+
repository = $PSRepository
23+
}
24+
}

0 commit comments

Comments
 (0)