Skip to content

Commit 75a7175

Browse files
committed
Define TEST constant when running tests
This cannot be in project files because we need it set for all projects. So we use an `ExtraDefineConstants` in the common properties file, and then add `TEST` to it at the time we run (and build) the tests themselves.
1 parent 0afa774 commit 75a7175

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

PowerShellEditorServices.Common.props

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<RepositoryType>git</RepositoryType>
1212
<RepositoryUrl>https://github.com/PowerShell/PowerShellEditorServices</RepositoryUrl>
1313
<DebugType>portable</DebugType>
14+
<DefineConstants Condition=" '$(ExtraDefineConstants)' != '' ">$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
1415
</PropertyGroup>
1516
</Project>

PowerShellEditorServices.build.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,20 @@ task TestServer TestServerWinPS,TestServerPS7,TestServerPS72
259259

260260
task TestServerWinPS -If (-not $script:IsNix) {
261261
Set-Location .\test\PowerShellEditorServices.Test\
262-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) }
262+
exec { & $script:dotnetExe test -p:ExtraDefineConstants=TEST --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) }
263263
}
264264

265265
task TestServerPS7 -If (-not $script:IsRosetta) {
266266
Set-Location .\test\PowerShellEditorServices.Test\
267267
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
268-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
268+
exec { & $script:dotnetExe test -p:ExtraDefineConstants=TEST --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
269269
}
270270
}
271271

272272
task TestServerPS72 {
273273
Set-Location .\test\PowerShellEditorServices.Test\
274274
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
275-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS72 (DotNetTestFilter) }
275+
exec { & $script:dotnetExe test -p:ExtraDefineConstants=TEST --logger trx -f $script:NetRuntime.PS72 (DotNetTestFilter) }
276276
}
277277
}
278278

@@ -281,13 +281,13 @@ task TestE2E {
281281

282282
$env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" }
283283
$NetRuntime = if ($IsRosetta) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 }
284-
exec { & $script:dotnetExe test --logger trx -f $NetRuntime (DotNetTestFilter) }
284+
exec { & $script:dotnetExe test -p:ExtraDefineConstants=TEST --logger trx -f $NetRuntime (DotNetTestFilter) }
285285

286286
# Run E2E tests in ConstrainedLanguage mode.
287287
if (!$script:IsNix) {
288288
try {
289289
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine);
290-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
290+
exec { & $script:dotnetExe test -p:ExtraDefineConstants=TEST --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
291291
} finally {
292292
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine);
293293
}

0 commit comments

Comments
 (0)