-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Only stop transcription when all runspaces are closed #3896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,4 +106,34 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" { | |
$expectedError = "CannotStartTranscription,Microsoft.PowerShell.Commands.StartTranscriptCommand" | ||
ValidateTranscription -scriptToExecute $script -outputFilePath $null -expectedError $expectedError | ||
} | ||
It "Transcription should remain active if other runspace in the host get closed" { | ||
try{ | ||
$ps = [powershell]::Create() | ||
$ps.addscript("Start-Transcript -path $transcriptFilePath").Invoke() | ||
$ps.addscript('$rs = [system.management.automation.runspaces.runspacefactory]::CreateRunspace()').Invoke() | ||
$ps.addscript('$rs.open()').Invoke() | ||
$ps.addscript('$rs.Dispose()').Invoke() | ||
$ps.addscript('Write-Host "After Dispose"').Invoke() | ||
$ps.addscript("Stop-Transcript").Invoke() | ||
} finally { | ||
if ($ps -ne $null) { | ||
$ps.Dispose() | ||
} | ||
} | ||
|
||
|
||
Test-Path $transcriptFilePath | Should be $true | ||
$transcriptFilePath | Should contain "After Dispose" | ||
} | ||
|
||
It "Transcription should be closed if the only runspace gets closed" { | ||
$powerShellPath = [System.Diagnostics.Process]::GetCurrentProcess().Path | ||
$powerShellCommand = $powerShellPath + ' "start-transcript $transcriptFilePath; Write-Host ''Before Dispose'';"' | ||
Invoke-Expression $powerShellCommand | ||
|
||
Test-Path $transcriptFilePath | Should be $true | ||
$transcriptFilePath | Should contain "Before Dispose" | ||
$transcriptFilePath | Should contain "Windows PowerShell transcript end" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add new line at the end of the file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AmsiUtils.Uninitialize() is still being called at line 930 below. Please remove that call so that uninitialize only happens when the last runspace closes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved