Fixing progress for Get-ComputerInfo (#9236)
This commit is contained in:
parent
074b344133
commit
4ec36a0d4a
|
@ -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>
|
||||
|
|
|
@ -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" {
|
||||
|
|
Loading…
Reference in a new issue