Skip to content

Commit 2f2a7c9

Browse files
authored
Suppress progress bar during testing (#569)
1 parent fefd7c7 commit 2f2a7c9

File tree

6 files changed

+495
-496
lines changed

6 files changed

+495
-496
lines changed

src/code/InstallHelper.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,11 @@ private List<PSResourceInfo> InstallPackage(
332332
if (!_quiet)
333333
{
334334
int activityId = 0;
335-
string activity = "";
336-
string statusDescription = "";
337-
338-
// Installing parent package (one whose name was passed in to install)
339-
activityId = 0;
340-
activity = string.Format("Installing {0}...", pkg.Name);
341-
statusDescription = string.Format("{0}% Complete:", Math.Round(((double)totalInstalledPkgCount / totalPkgs) * 100), 2);
342-
343-
var progressRecord = new ProgressRecord(activityId, activity, statusDescription);
344-
_cmdletPassedIn.WriteProgress(progressRecord);
335+
int percentComplete = ((totalInstalledPkgCount * 100) / totalPkgs);
336+
string activity = string.Format("Installing {0}...", pkg.Name);
337+
string statusDescription = string.Format("{0}% Complete", percentComplete);
338+
_cmdletPassedIn.WriteProgress(
339+
new ProgressRecord(activityId, activity, statusDescription));
345340
}
346341

347342
// Create PackageIdentity in order to download

test/GetInstalledPSResource.Tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
$ProgressPreference = "SilentlyContinue"
45
Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force
56

67
Describe 'Test Get-PSResource for Module' {

test/InstallPSResource.Tests.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
$ProgressPreference = "SilentlyContinue"
45
Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force
56

67
Describe 'Test Install-PSResource for Module' {
78

89
BeforeAll {
9-
$OldProgressPreference = $ProgressPreference
10-
$ProgressPreference = "SilentlyContinue"
1110
$TestGalleryName = Get-PoshTestGalleryName
1211
$PSGalleryName = Get-PSGalleryName
1312
$NuGetGalleryName = Get-NuGetGalleryName
@@ -23,7 +22,6 @@ Describe 'Test Install-PSResource for Module' {
2322
}
2423

2524
AfterAll {
26-
$ProgressPreference = $OldProgressPreference
2725
Get-RevertPSResourceRepositoryFile
2826
}
2927

0 commit comments

Comments
 (0)