Default to DefaultConsoleWidth when DotNet says WindowWidth is 0#7465
Default to DefaultConsoleWidth when DotNet says WindowWidth is 0#7465TravisEz13 merged 5 commits intoPowerShell:masterfrom
Conversation
|
@TravisEz13 Please look #6883 - could we move commits from #6883 to the PR? |
|
@iSazonov I knew I saw this before, thanks |
| internal static bool StopwatchIsNotHighResolution; | ||
| internal static bool DisableGACLoading; | ||
| internal static bool SetConsoleWidthToZero; | ||
| <<<<<<< HEAD |
There was a problem hiding this comment.
merge headers are left here.
| # Fill the console window with the string, so that it reaches its max width. | ||
| # Check if the max width is equal to default value (120), to test test hook set. | ||
| $testObject = @{ test = '1' * 200} | ||
| Format-table -inputobject $testObject | Out-String -Stream | ForEach-Object{$_.length} | Sort-Object | Select-Object -Last 1 | Should -Be 120 |
There was a problem hiding this comment.
use
Format-table -inputobject $testObject | Out-String -Stream | ForEach-Object{$_.length} | Sort-Object -Bottom 1| # Check if the max width is equal to default value (120), to test test hook set. | ||
| $testObject = @{ test = '1' * 200} | ||
| Format-table -inputobject $testObject | Out-String -Stream | ForEach-Object{$_.length} | Sort-Object | Select-Object -Last 1 | Should -Be 120 | ||
| Format-Table -inputobject $testObject | Should -Not -BeNullOrEmpty |
|
@TravisEz13 There seems to be a new CodeFactor issue. Can you have a look. |
|
The CodeFactor issue is basically an existing design issue around the test hooks |
|
We have |
|
We would have to have something that allows us to mock |
|
I found related discussion https://stackoverflow.com/questions/5852862/mocking-system-console-behaviour
|
PR Summary
Default to DefaultConsoleWidth when DotNet says WindowWidth is 0
This resolves an issue in an environment like VSTS when pwsh is spawned and DotNet is not able to determine the Console Width.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests