From b6d4ef09cb2755628d9ff3d10c231cad0ff6097f Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 14 Jun 2023 11:49:57 -0700 Subject: [PATCH] Fix logic for Import-CliXml test. The current logic doesn't ensure that the stop processing (if delivered) is executed during the import operation. By creating a more than trivial clixml file and looping we can ensure that we are executing when StopProcessing is called. --- .../XMLCommand.Tests.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 index ea631d7f6f9..53e4fbf8d7d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1 @@ -244,11 +244,15 @@ Describe "XmlCommand DRT basic functionality Tests" -Tags "CI" { } It "Import-Clixml StopProcessing should succeed" { - 1,2,3 | Export-Clixml -Path $testfile + # create a file to use for import. It should have some complexity + Get-Process -Id $PID | Export-Clixml -Path $testfile + # create a large number of files to import + $script = '$f = ,"' + $testfile + '" * 1000' $ps = [PowerShell]::Create() - $ps.AddCommand("Get-Process") - $ps.AddCommand("Import-CliXml") - $ps.AddParameter("Path", $testfile) + $ps.AddScript($script) + $ps.Invoke() + $ps.Commands.Clear() + $ps.AddScript('$null = Import-CliXml -Path $f') $ps.BeginInvoke() $ps.Stop() $ps.InvocationStateInfo.State | Should -Be "Stopped"