@@ -48,17 +48,18 @@ $script:IsArm64 = -not $script:IsNix -and @("ARM64") -contains $env:PROCESSOR_AR
48
48
$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
49
49
$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
50
50
51
- $script :NetRuntime = @ {
51
+ $script :NetFramework = @ {
52
+ PS51 = ' net462'
52
53
PS72 = ' net6.0'
53
54
PS73 = ' net7.0'
54
- Desktop = ' net462 '
55
+ PS74 = ' net8.0 '
55
56
Standard = ' netstandard2.0'
56
57
}
57
58
58
- $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime .PS72 ) /publish"
59
- $script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime .Desktop ) /publish"
60
- $script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime .Standard ) /publish"
61
- $script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime .Standard ) /publish"
59
+ $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetFramework .PS72 ) /publish"
60
+ $script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetFramework .PS51 ) /publish"
61
+ $script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetFramework .Standard ) /publish"
62
+ $script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetFramework .Standard ) /publish"
62
63
63
64
if (Get-Command git - ErrorAction SilentlyContinue) {
64
65
# ignore changes to this file
@@ -157,63 +158,105 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
157
158
}
158
159
159
160
Task SetupHelpForTests {
160
- if (-not (Get-Help Microsoft.PowerShell.Management\Get-Process ).Description) {
161
+ # Checks if the description is filled out (otherwise it just shows the syntax).
162
+ if (((Get-Help Microsoft.PowerShell.Management\Get-Process ).Description.Text | Select-Object - First 1 ) -notmatch " cmdlet" ) {
161
163
Write-Host " Updating help for tests."
162
164
Update-Help - Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility - Force - Scope CurrentUser
163
165
}
164
166
}
165
167
166
168
Task Build FindDotNet, CreateBuildInfo, {
167
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime .Standard }
168
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime .PS72 }
169
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetFramework .Standard }
170
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetFramework .PS72 }
169
171
170
172
if (-not $script :IsNix ) {
171
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime .Desktop }
173
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetFramework .PS51 }
172
174
}
173
175
174
176
# Build PowerShellEditorServices.VSCode module
175
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime .Standard }
177
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetFramework .Standard }
176
178
}
177
179
178
- Task Test TestServer, TestE2E, TestConstrainedLanguageMode
180
+ # The concise set of tests (for pull requests)
181
+ Task Test TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell
179
182
180
- Task TestServer SetupHelpForTests, TestServerWinPS, TestServerPS72, TestServerPS73
183
+ # Every combination of tests (for main branch)
184
+ Task TestFull Test, TestPS73, TestPS72, TestE2EPwshCLM, TestE2EPowerShellCLM
181
185
182
- Task TestE2E SetupHelpForTests, TestE2EPwsh, TestE2EWinPS
186
+ Task TestPS74 Build, SetupHelpForTests, {
187
+ Set-Location .\test\PowerShellEditorServices.Test\
188
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
189
+ }
183
190
184
- Task TestServerWinPS - If ( -not $ script :IsNix ) Build, {
191
+ Task TestPS73 Build, SetupHelpForTests , {
185
192
Set-Location .\test\PowerShellEditorServices.Test\
186
- # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
187
- # that is debuggable! If architecture is added, the assembly path gets an
188
- # additional folder, necesstiating fixes to find the commands definition
189
- # file and test files.
190
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
193
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS73 }
191
194
}
192
195
193
- Task TestServerPS72 Build, {
196
+ Task TestPS72 Build, SetupHelpForTests , {
194
197
Set-Location .\test\PowerShellEditorServices.Test\
195
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime .PS72 }
198
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework .PS72 }
196
199
}
197
200
198
- Task TestServerPS73 Build, {
201
+ Task TestPS51 - If ( -not $ script :IsNix ) Build, SetupHelpForTests , {
199
202
Set-Location .\test\PowerShellEditorServices.Test\
200
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
203
+ # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
204
+ # that is debuggable! If architecture is added, the assembly path gets an
205
+ # additional folder, necessitating fixes to find the commands definition
206
+ # file and test files.
207
+ try {
208
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
209
+ # Inheriting the module path for powershell.exe breaks things!
210
+ $originalModulePath = $env: PSModulePath
211
+ $env: PSModulePath = " "
212
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS51 }
213
+ } finally {
214
+ $env: PSModulePath = $originalModulePath
215
+ }
201
216
}
202
217
203
- Task TestE2EPwsh Build, {
218
+ # NOTE: The framework for the E2E tests applies to the mock client, and so
219
+ # should just be the latest supported framework.
220
+ Task TestE2EPwsh Build, SetupHelpForTests, {
204
221
Set-Location .\test\PowerShellEditorServices.Test.E2E\
205
222
$env: PWSH_EXE_NAME = " pwsh"
206
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime .PS73 }
223
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework .PS74 }
207
224
}
208
225
209
- Task TestE2EWinPS - If ( -not $ script :IsNix ) Build, {
226
+ Task TestE2EPowerShell Build, SetupHelpForTests , {
210
227
Set-Location .\test\PowerShellEditorServices.Test.E2E\
211
228
$env: PWSH_EXE_NAME = " powershell"
212
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
229
+ try {
230
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
231
+ # Inheriting the module path for powershell.exe breaks things!
232
+ $originalModulePath = $env: PSModulePath
233
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
234
+ } finally {
235
+ $env: PSModulePath = $originalModulePath
236
+ }
213
237
}
214
238
215
- Task TestConstrainedLanguageMode - If (-not $script :IsNix ) Build, {
239
+ Task TestE2EPwshCLM - If (-not $script :IsNix ) Build, SetupHelpForTests , {
216
240
Set-Location .\test\PowerShellEditorServices.Test.E2E\
241
+ $env: PWSH_EXE_NAME = " pwsh"
242
+
243
+ if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
244
+ Write-Warning " Skipping Constrained Language Mode tests as they must be ran in an elevated process."
245
+ return
246
+ }
247
+
248
+ try {
249
+ Write-Host " Running end-to-end tests in Constrained Language Mode."
250
+ [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
251
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
252
+ } finally {
253
+ [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
254
+ }
255
+ }
256
+
257
+ Task TestE2EPowerShellCLM - If (-not $script :IsNix ) Build, SetupHelpForTests, {
258
+ Set-Location .\test\PowerShellEditorServices.Test.E2E\
259
+ $env: PWSH_EXE_NAME = " powershell"
217
260
218
261
if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
219
262
Write-Warning " Skipping Constrained Language Mode tests as they must be ran in an elevated process."
@@ -223,9 +266,13 @@ Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, {
223
266
try {
224
267
Write-Host " Running end-to-end tests in Constrained Language Mode."
225
268
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
226
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
269
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
270
+ # Inheriting the module path for powershell.exe breaks things!
271
+ $originalModulePath = $env: PSModulePath
272
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
227
273
} finally {
228
274
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
275
+ $env: PSModulePath = $originalModulePath
229
276
}
230
277
}
231
278
0 commit comments