Fixing progress for Get-ComputerInfo (#9236)

This commit is contained in:
Staffan Gustafsson 2019-04-05 01:15:44 +02:00 committed by Aditya Patwardhan
parent 074b344133
commit 4ec36a0d4a
2 changed files with 15 additions and 11 deletions

View file

@ -85,7 +85,6 @@ namespace Microsoft.PowerShell.Commands
#region Instance Data
private string _machineName = localMachineName; // we might need to have cmdlet work on another machine
private ProgressRecord _progress = null;
/// <summary>
/// Collection of property names from the Property parameter,
@ -225,17 +224,10 @@ namespace Microsoft.PowerShell.Commands
/// </param>
private void UpdateProgress(string status)
{
if (_progress != null)
{
_progress.RecordType = ProgressRecordType.Completed;
WriteProgress(_progress);
}
ProgressRecord progress = new ProgressRecord(0, activity, status ?? ComputerResources.ProgressStatusCompleted);
progress.RecordType = status == null ? ProgressRecordType.Completed : ProgressRecordType.Processing;
if (status != null)
{
_progress = new ProgressRecord(0, activity, status);
WriteProgress(_progress);
}
WriteProgress(progress);
}
/// <summary>

View file

@ -1010,6 +1010,18 @@ try {
$computerInfo = Get-ComputerInfo
$computerInfo | Should -BeOfType 'Microsoft.PowerShell.Commands.ComputerInfo'
}
It "Verify progress records in Get-ComputerInfo" {
try {
$j = Start-Job { Get-ComputerInfo }
$j | Wait-Job
$j.ChildJobs[0].Progress | Should -HaveCount 9
$j.ChildJobs[0].Progress[-1].RecordType | Should -Be ([System.Management.Automation.ProgressRecordType]::Completed)
}
finally {
$j | Remove-Job
}
}
}
Describe "Tests for Get-ComputerInfo" -tags "Feature", "RequireAdminOnWindows" {