From 6e4b6e9fa139898b0b7789d6ed9f3aecf34860db Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 08:45:36 -0700 Subject: [PATCH 1/8] Add Out-String -Width 80 to Format-Table commands so that the command could work also without console dimensions specified. --- test/powershell/Host/PSVersionTable.Tests.ps1 | 8 +-- .../Format-Table.Tests.ps1 | 57 ++++++++----------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index c3fc1ab2f6c..88ef88a19a6 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -86,7 +86,7 @@ Describe "PSVersionTable" -Tags "CI" { It "Verify `$PSVersionTable is ordered and 'PSVersion' is on first place" { $PSVersionName = "PSVersion" - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSVersion" $keys1[1] | Should -Be "PSEdition" @@ -112,7 +112,7 @@ Describe "PSVersionTable" -Tags "CI" { $VersionValue = $PSVersionTable["PSVersion"] $PSVersionTable.Remove("PSVersion") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSEdition" $keys1.Length | Should -Be $PSVersionTable.Count @@ -129,7 +129,7 @@ Describe "PSVersionTable" -Tags "CI" { $EditionValue = $PSVersionTable["PSEdition"] $PSVersionTable.Remove("PSEdition") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSVersion" $keys1.Length | Should -Be $PSVersionTable.Count @@ -148,7 +148,7 @@ Describe "PSVersionTable" -Tags "CI" { $PSVersionTable.Remove("PSVersion") $PSVersionTable.Remove("PSEdition") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1.Length | Should -Be $PSVersionTable.Count $keys1sortedlast = $keys1 | Sort-Object diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 index 3f79b0a380d..c4574614209 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 @@ -30,67 +30,60 @@ Describe "Format-Table" -Tags "CI" { $al = (0..255) $info = @{} $info.array = $al - $result = $info | Format-Table | Out-String + $result = $info | Format-Table | Out-String -Width 80 $result | Should -Match "array\s+{0, 1, 2, 3...}" } It "Format-Table with Negative Count should work" { $FormatEnumerationLimit = -1 - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{1, 2}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{1, 2}" } # Pending on issue#888 It "Format-Table with Zero Count should work" -Pending { $FormatEnumerationLimit = 0 - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{...}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{...}" } It "Format-Table with Less Count should work" { $FormatEnumerationLimit = 1 - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{1...}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{1...}" } It "Format-Table with More Count should work" { $FormatEnumerationLimit = 10 - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{1, 2}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{1, 2}" } It "Format-Table with Equal Count should work" { $FormatEnumerationLimit = 2 - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{1, 2}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{1, 2}" } # Pending on issue#888 It "Format-Table with Bogus Count should throw Exception" -Pending { $FormatEnumerationLimit = "abc" - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result|Out-String - $resultStr | Should -Match "test\s+{1, 2}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String + $result | Should -Match "test\s+{1, 2}" } # Pending on issue#888 It "Format-Table with Var Deleted should throw Exception" -Pending { $FormatEnumerationLimit = 2 Remove-Variable FormatEnumerationLimit - $result = Format-Table -inputobject @{'test'= 1, 2} - $resultStr = $result | Out-String - $resultStr | Should -Match "test\s+{1, 2}" + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result | Should -Match "test\s+{1, 2}" } It "Format-Table with new line should work" { $info = @{} $info.name = "1\n2" - $result = $info | Format-Table | Out-String + $result = $info | Format-Table | Out-String -Width 80 $result | Should -Match "name\s+1.+2" } @@ -112,7 +105,7 @@ Describe "Format-Table" -Tags "CI" { $IPs = New-Object System.Collections.ArrayList $IPs.Add($IP1) $IPs.Add($IP2) - $result = $IPs | Format-Table -Autosize | Out-String + $result = $IPs | Format-Table -Autosize | Out-String -Width 80 $result | Should -Match "name size booleanValue" $result | Should -Match "---- ---- ------------" $result | Should -Match "Bob\s+1234\s+True" @@ -124,7 +117,7 @@ Describe "Format-Table" -Tags "CI" { @{ testName = "null" ; testObject = $null } ) { param ($testObject) - $result = $testObject | Format-Table -Property "foo","bar" | Out-String + $result = $testObject | Format-Table -Property "foo","bar" | Out-String -Width 80 $result | Should -BeNullOrEmpty } @@ -134,7 +127,7 @@ Describe "Format-Table" -Tags "CI" { @{ testName = "array" ; testString = "line1","line2" } ) { param ($testString) - $result = $testString | Format-Table -Property "foo","bar" -Force | Out-String + $result = $testString | Format-Table -Property "foo","bar" -Force | Out-String -Width 80 $result.Replace(" ","").Replace([Environment]::NewLine,"") | Should -BeExactly "foobar------" } @@ -146,7 +139,7 @@ Describe "Format-Table" -Tags "CI" { $info.arrayList = "string1","string2" $info.enumerable = [MyDayOfWeek]$eto $info.enumerableTestObject = $eto - $result = $info|Format-Table|Out-String + $result = $info | Format-Table | Out-String -Width 80 $result | Should -Match "intArray\s+{1, 2, 3, 4}" $result | Should -Match "arrayList\s+{string1, string2}" $result | Should -Match "enumerable\s+Sun" @@ -160,26 +153,26 @@ Describe "Format-Table" -Tags "CI" { $objs.Add($obj1) $objs.Add($obj2) $mo = [PSCustomObject]@{name = "this is name";sub = $objs} - $result1 = $mo|Format-Table -Expand CoreOnly|Out-String + $result1 = $mo | Format-Table -Expand CoreOnly | Out-String -Width 80 $result1 | Should -Match "name\s+sub" $result1 | Should -Match "this is name" - $result2 = $mo|Format-Table -Expand EnumOnly|Out-String + $result2 = $mo | Format-Table -Expand EnumOnly | Out-String -Width 80 $result2 | Should -Match "name\s+sub" $result2 | Should -Match "this is name\s+{x 0 y 0, x 1 y 1}" - $result3 = $mo|Format-Table -Expand Both|Out-String + $result3 = $mo | Format-Table -Expand Both | Out-String -Width 80 $result3 | Should -Match "name\s+sub" $result3 | Should -Match "this is name\s+{x 0 y 0, x 1 y 1}" } It "Format-Table should not add trailing whitespace to the header" { - $out = "hello" | Format-Table -Property foo -Force | Out-String + $out = "hello" | Format-Table -Property foo -Force | Out-String -Width 80 $out.Replace([System.Environment]::NewLine, "") | Should -BeExactly "foo---" } It "Format-Table should not add trailing whitespace to rows" { - $out = [pscustomobject]@{a=1;b=2} | Format-Table -HideTableHeaders | Out-String + $out = [pscustomobject]@{a=1;b=2} | Format-Table -HideTableHeaders | Out-String -Width 80 $out.Replace([System.Environment]::NewLine, "") | Should -BeExactly "1 2" } From 3f2a03a687cf072c247a6695f27ee02a8cd50bd8 Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 10:19:39 -0700 Subject: [PATCH 2/8] Add Out-String -Width 120 to Format-Table tests --- .../Microsoft.PowerShell.Management.psd1 | 2 +- .../Format-Table.Tests.ps1 | 49 ++++++++++--------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 b/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 index ce0b1442968..1840bbe21fa 100644 --- a/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 +++ b/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 @@ -45,7 +45,7 @@ CmdletsToExport=@("Add-Content", "Wait-Process", "Debug-Process", "Start-Process", - "Test-Connection", + "Test-Connection", "Remove-ItemProperty", "Rename-ItemProperty", "Resolve-Path", diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 index c4574614209..ce0f5f2fa70 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 @@ -1,6 +1,12 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. Describe "Format-Table" -Tags "CI" { + It "my test" { + $result = @{'test'=1,2} | Format-Table + $resultStr = $result | Out-String + Write-Host "writing" + Write-Host $resultStr + } It "Should call format table on piped input without error" { { Get-Date | Format-Table } | Should -Not -Throw } @@ -30,38 +36,38 @@ Describe "Format-Table" -Tags "CI" { $al = (0..255) $info = @{} $info.array = $al - $result = $info | Format-Table | Out-String -Width 80 + $result = $info | Format-Table | Out-String -Width 120 $result | Should -Match "array\s+{0, 1, 2, 3...}" } It "Format-Table with Negative Count should work" { $FormatEnumerationLimit = -1 - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{1, 2}" } # Pending on issue#888 It "Format-Table with Zero Count should work" -Pending { $FormatEnumerationLimit = 0 - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{...}" } It "Format-Table with Less Count should work" { $FormatEnumerationLimit = 1 - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{1...}" } It "Format-Table with More Count should work" { $FormatEnumerationLimit = 10 - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{1, 2}" } It "Format-Table with Equal Count should work" { $FormatEnumerationLimit = 2 - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{1, 2}" } @@ -76,14 +82,14 @@ Describe "Format-Table" -Tags "CI" { It "Format-Table with Var Deleted should throw Exception" -Pending { $FormatEnumerationLimit = 2 Remove-Variable FormatEnumerationLimit - $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 80 + $result = Format-Table -inputobject @{'test'= 1, 2} | Out-String -Width 120 $result | Should -Match "test\s+{1, 2}" } It "Format-Table with new line should work" { $info = @{} $info.name = "1\n2" - $result = $info | Format-Table | Out-String -Width 80 + $result = $info | Format-Table | Out-String -Width 120 $result | Should -Match "name\s+1.+2" } @@ -95,7 +101,7 @@ Describe "Format-Table" -Tags "CI" { $IPs.Add($IP2) $info = @{} $info.test = $IPs - $result = $info | Format-Table | Out-String + $result = $info | Format-Table | Out-String -Width 120 $result | Should -Match "test\s+{1.1.1.1, 4fde::2:22:f376:ff3b:ab3f}" } @@ -105,7 +111,7 @@ Describe "Format-Table" -Tags "CI" { $IPs = New-Object System.Collections.ArrayList $IPs.Add($IP1) $IPs.Add($IP2) - $result = $IPs | Format-Table -Autosize | Out-String -Width 80 + $result = $IPs | Format-Table -Autosize | Out-String -Width 120 $result | Should -Match "name size booleanValue" $result | Should -Match "---- ---- ------------" $result | Should -Match "Bob\s+1234\s+True" @@ -117,7 +123,7 @@ Describe "Format-Table" -Tags "CI" { @{ testName = "null" ; testObject = $null } ) { param ($testObject) - $result = $testObject | Format-Table -Property "foo","bar" | Out-String -Width 80 + $result = $testObject | Format-Table -Property "foo","bar" | Out-String -Width 120 $result | Should -BeNullOrEmpty } @@ -127,7 +133,7 @@ Describe "Format-Table" -Tags "CI" { @{ testName = "array" ; testString = "line1","line2" } ) { param ($testString) - $result = $testString | Format-Table -Property "foo","bar" -Force | Out-String -Width 80 + $result = $testString | Format-Table -Property "foo","bar" -Force | Out-String -Width 120 $result.Replace(" ","").Replace([Environment]::NewLine,"") | Should -BeExactly "foobar------" } @@ -139,7 +145,7 @@ Describe "Format-Table" -Tags "CI" { $info.arrayList = "string1","string2" $info.enumerable = [MyDayOfWeek]$eto $info.enumerableTestObject = $eto - $result = $info | Format-Table | Out-String -Width 80 + $result = $info | Format-Table | Out-String -Width 120 $result | Should -Match "intArray\s+{1, 2, 3, 4}" $result | Should -Match "arrayList\s+{string1, string2}" $result | Should -Match "enumerable\s+Sun" @@ -153,26 +159,26 @@ Describe "Format-Table" -Tags "CI" { $objs.Add($obj1) $objs.Add($obj2) $mo = [PSCustomObject]@{name = "this is name";sub = $objs} - $result1 = $mo | Format-Table -Expand CoreOnly | Out-String -Width 80 + $result1 = $mo | Format-Table -Expand CoreOnly | Out-String -Width 120 $result1 | Should -Match "name\s+sub" $result1 | Should -Match "this is name" - $result2 = $mo | Format-Table -Expand EnumOnly | Out-String -Width 80 + $result2 = $mo | Format-Table -Expand EnumOnly | Out-String -Width 120 $result2 | Should -Match "name\s+sub" $result2 | Should -Match "this is name\s+{x 0 y 0, x 1 y 1}" - $result3 = $mo | Format-Table -Expand Both | Out-String -Width 80 + $result3 = $mo | Format-Table -Expand Both | Out-String -Width 120 $result3 | Should -Match "name\s+sub" $result3 | Should -Match "this is name\s+{x 0 y 0, x 1 y 1}" } It "Format-Table should not add trailing whitespace to the header" { - $out = "hello" | Format-Table -Property foo -Force | Out-String -Width 80 + $out = "hello" | Format-Table -Property foo -Force | Out-String -Width 120 $out.Replace([System.Environment]::NewLine, "") | Should -BeExactly "foo---" } It "Format-Table should not add trailing whitespace to rows" { - $out = [pscustomobject]@{a=1;b=2} | Format-Table -HideTableHeaders | Out-String -Width 80 + $out = [pscustomobject]@{a=1;b=2} | Format-Table -HideTableHeaders | Out-String -Width 120 $out.Replace([System.Environment]::NewLine, "") | Should -BeExactly "1 2" } @@ -316,7 +322,7 @@ Left Center Right param($ps1xmlPath,$view,$object) Update-FormatData -AppendPath $ps1xmlPath $object.PSObject.TypeNames.Insert(0,"Test.Format") - $object | Format-Table -View $view | Out-String + $object | Format-Table -View $view | Out-String -Width 120 } ).AddArgument($ps1xmlPath).AddArgument($view).AddArgument($object) | Out-Null $output = $ps.Invoke() $output.Replace("`n","").Replace("`r","") | Should -BeExactly $expected @@ -448,7 +454,7 @@ er Update-FormatData -AppendPath $ps1xmlPath $a = [PSCustomObject]@{First=1;Second=2;Third=3} $a.PSObject.TypeNames.Insert(0,"Test.Format") - $a | Format-Table -View $view | Out-String + $a | Format-Table -View $view | Out-String -Width 120 } ).AddArgument($ps1xmlPath).AddArgument($view) | Out-Null $output = $ps.Invoke() foreach ($e in $ps.Streams.Error) @@ -461,7 +467,6 @@ er It "Format-Table should correctly render rows: " -TestCases @( @{ view = "Default"; widths = 4,7,5; variation = "narrow values"; values = [PSCustomObject]@{First=1;Second=2;Third=3}; wrap = $false; expectedTable = @" - Long*Header2*Heade Long*********r3 Head @@ -653,7 +658,7 @@ er param($ps1xmlPath, $view, $values, $wrap) Update-FormatData -AppendPath $ps1xmlPath $values.PSObject.TypeNames.Insert(0,"Test.Format") - $values | Format-Table -View $view -Wrap:$wrap | Out-String + $values | Format-Table -View $view -Wrap:$wrap | Out-String -Width 120 } ).AddArgument($ps1xmlPath).AddArgument($view).AddArgument($values).AddArgument($wrap) | Out-Null $output = $ps.Invoke() foreach ($e in $ps.Streams.Error) From 6cfae1f01a094df58add8ba898a7f128aecc1d3d Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 10:23:19 -0700 Subject: [PATCH 3/8] Add -Width parameter to Format-Wide tests. --- .../Microsoft.PowerShell.Utility/Format-Wide.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Wide.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Wide.Tests.ps1 index f10f9f38649..7c83d26988c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Wide.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Wide.Tests.ps1 @@ -39,7 +39,7 @@ Describe "Format-Wide DRT basic functionality" -Tags "CI" { $al = (0..255) $info = @{} $info.array = $al - $result = $info | Format-Wide | Out-String + $result = $info | Format-Wide | Out-String -Width 120 $result | Should -Match "array" } @@ -83,7 +83,7 @@ Describe "Format-Wide DRT basic functionality" -Tags "CI" { $info.arrayList = "string1", "string2" $info.enumerable = [MyDayOfWeek]$eto $info.enumerableTestObject = $eto - $result = $info|Format-Wide|Out-String + $result = $info | Format-Wide | Out-String -Width 120 $result | Should -Match "intArray" $result | Should -Match "arrayList" $result | Should -Match "enumerable" @@ -99,7 +99,7 @@ Describe "Format-Wide DRT basic functionality" -Tags "CI" { $testobject3 = [TestGroupingClass]::New('name3', 3) $testobject1.GroupingKey = "bar" $testobjects = @($testobject1, $testobject2, $testobject3) - $result = $testobjects|Format-Wide -GroupBy GroupingKey|Out-String + $result = $testobjects | Format-Wide -GroupBy GroupingKey | Out-String -Width 120 $result | Should -Match "GroupingKey: bar" $result | Should -Match "name1" $result | Should -Match " GroupingKey:" From bbfd402003dac4371bac9ccaa3337b1f2f36c50a Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 19:09:39 -0800 Subject: [PATCH 4/8] Add -Width parameter for tests in Scripting.Classes.BasicParsing.Tests --- .../Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index 1d017ce11a1..615072116aa 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -572,7 +572,7 @@ Describe 'Hidden Members Test ' -Tags "CI" { It "Access hidden property should still work" { $instance.hiddenZ | Should -Be 42 } # Formatting should not include hidden members by default - $tableOutput = $instance | Format-Table -HideTableHeaders -AutoSize | Out-String + $tableOutput = $instance | Format-Table -HideTableHeaders -AutoSize | Out-String -Width 120 It "Table formatting should not have included hidden member hiddenZ - should contain 10" { $tableOutput.Contains(10) | Should -BeTrue} It "Table formatting should not have included hidden member hiddenZ- should contain 12" { $tableOutput.Contains(12) | Should -BeTrue} It "Table formatting should not have included hidden member hiddenZ - should not contain 42" { $tableOutput.Contains(42) | Should -BeFalse} From e1403c417d6912847de3713578ed49e68490bf8b Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 20:23:46 -0800 Subject: [PATCH 5/8] Revert accidental changes. --- .../Microsoft.PowerShell.Management.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 b/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 index 1840bbe21fa..ce0b1442968 100644 --- a/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 +++ b/src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 @@ -45,7 +45,7 @@ CmdletsToExport=@("Add-Content", "Wait-Process", "Debug-Process", "Start-Process", - "Test-Connection", + "Test-Connection", "Remove-ItemProperty", "Rename-ItemProperty", "Resolve-Path", From 1c305dece79e804fd8a8e0fb5fab09b07b6acb40 Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 20:27:54 -0800 Subject: [PATCH 6/8] Default value of width parameter change. --- test/powershell/Host/PSVersionTable.Tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index 88ef88a19a6..b6fb0541d5a 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -86,7 +86,7 @@ Describe "PSVersionTable" -Tags "CI" { It "Verify `$PSVersionTable is ordered and 'PSVersion' is on first place" { $PSVersionName = "PSVersion" - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 120) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSVersion" $keys1[1] | Should -Be "PSEdition" @@ -112,7 +112,7 @@ Describe "PSVersionTable" -Tags "CI" { $VersionValue = $PSVersionTable["PSVersion"] $PSVersionTable.Remove("PSVersion") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 120) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSEdition" $keys1.Length | Should -Be $PSVersionTable.Count @@ -129,7 +129,7 @@ Describe "PSVersionTable" -Tags "CI" { $EditionValue = $PSVersionTable["PSEdition"] $PSVersionTable.Remove("PSEdition") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 120) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1[0] | Should -Be "PSVersion" $keys1.Length | Should -Be $PSVersionTable.Count @@ -148,7 +148,7 @@ Describe "PSVersionTable" -Tags "CI" { $PSVersionTable.Remove("PSVersion") $PSVersionTable.Remove("PSEdition") - $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 80) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} + $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String -Width 120) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} $keys1.Length | Should -Be $PSVersionTable.Count $keys1sortedlast = $keys1 | Sort-Object From 98bbdb8ca17e2ef1eceeb4e564bf592a620a944f Mon Sep 17 00:00:00 2001 From: kalgiz Date: Fri, 27 Apr 2018 20:29:54 -0800 Subject: [PATCH 7/8] Remove Debug messages. --- .../Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 index ce0f5f2fa70..fd3ef7e2920 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 @@ -1,12 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. Describe "Format-Table" -Tags "CI" { - It "my test" { - $result = @{'test'=1,2} | Format-Table - $resultStr = $result | Out-String - Write-Host "writing" - Write-Host $resultStr - } It "Should call format table on piped input without error" { { Get-Date | Format-Table } | Should -Not -Throw } From d7398f0fa34ed97847e432323ecc42b90e5feb72 Mon Sep 17 00:00:00 2001 From: kalgiz Date: Mon, 30 Apr 2018 04:59:12 -0800 Subject: [PATCH 8/8] Add empty line in string, which previously was accidentally removed. --- .../Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 index fd3ef7e2920..332cfb7da34 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 @@ -461,6 +461,7 @@ er It "Format-Table should correctly render rows: " -TestCases @( @{ view = "Default"; widths = 4,7,5; variation = "narrow values"; values = [PSCustomObject]@{First=1;Second=2;Third=3}; wrap = $false; expectedTable = @" + Long*Header2*Heade Long*********r3 Head