Skip to content

Commit c4321d8

Browse files
Make concurrency test safe against Helper singleton initialization order
Co-authored-by: jessehouwing <4173387+jessehouwing@users.noreply.github.com>
1 parent 476e1a3 commit c4321d8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Tests/Engine/CommandInfoCacheConcurrency.tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
Describe "Concurrent command lookups" {
55
BeforeAll {
6+
# Run the analyzer once so that the singleton Helper is created by the cmdlet. Touching
7+
# Helper.Instance before that would install a helper without a command invocation context,
8+
# which breaks every later analysis in this process.
9+
$null = Invoke-ScriptAnalyzer -ScriptDefinition 'Get-Item -Path .'
10+
611
# The concurrency driver is written in C# so that the lookups really do run on separate
712
# threads. Invoking a PowerShell script block on a thread pool thread would introduce
813
# runspace affinity problems of its own and would not test the command info cache.

0 commit comments

Comments
 (0)