iainbrighton / PScribo

PowerShell documentation framework
MIT License
231 stars 35 forks source link

Compatibility of tests with PowerShell Core on Linux #54

Closed it-praktyk closed 4 years ago

it-praktyk commented 7 years ago

Recently I updated my PowerShell module New-OutputObject to be compatible with PowerShell Core on Linux and MacOS.

The function Test-CharsInPath is part of #53 . But I run all PScribo tests on Linux too.

I see at least two types of tests failures

Case 1 - usage of Get-Service as a source of content for tests.

Describing Style\Set-PScriboStyle
   Context By Row.
    [-] sets row style by reference. 146ms
      The term 'Get-Service' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
      at line: 178 in /home/<USERNAME>/Downloads/PScribo/Tests/Unit/Style.Tests.ps1

Case 2 - EOL char(s) are different in Windows and Linux

Describing OutText.Internal\OutTextBlankLine
 [-] Defaults to a single blank line. 120ms
   Expected string length 2 but was 1. Strings differ at index 0.
   Expected: {\r\n}
   But was:  {\n}
   -----------^
   at line: 82 in /home/wojtek/Downloads/PScribo/Tests/Plugins/OutText.Tests.ps1
   82:             $l | Should Be "`r`n";
 [-] Creates 3 blank lines. 25ms
   Expected string length 6 but was 3. Strings differ at index 0.
   Expected: {\r\n\r\n\r\n}
   But was:  {\n\n\n}

Are you interested to make PScribo tests compatible with PowerShell Core on different platforms than Linux?

iainbrighton commented 7 years ago

I guess the tests could be updated to use the [System.Environment]::NewLine enum. Presumably this just returns \n in .NET Core on Linux? As for the services, they could be changed to use Get-Process instead?

it-praktyk commented 7 years ago

@iainbrighton, I work now to achieve compatibility of Pester with PSCore - https://github.com/pester/Pester/issues/639. After that, I can return to this case too.

it-praktyk commented 6 years ago

@iainbrighton, please reopen it. Thank you.

iainbrighton commented 4 years ago

@it-praktyk Hopefully all the tests should now pass on Linux. Can you test and confirm? Thanks, Iain

it-praktyk commented 4 years ago

I see a long list of failed tests, e.g.

Executing script /home/<folder_name>/PScribo/Tests/Plugins/Text/Out-TextBlankLine.Tests.ps1

  Describing Plugins\Text\Out-TextBlankLine
    [-] Error occurred in Describe block 0ms
      PropertyNotFoundException: The property 'TotalProcessingTime' cannot be found on this object. Verify that the property exists.
      at Document<Process>, <No file>: line 84
      at <ScriptBlock>, /home/<folder_name>/PScribo/Tests/Plugins/Text/Out-TextBlankLine.Tests.ps1: line 12
      at DescribeImpl, /home/<user_name>/.local/share/powershell/Modules/Pester/4.10.1/Functions/Describe.ps1: line 213

About a week ago I've tested the PScribo and tests passed then. Today, I've updated PSCore to 7.0.0 GA.

iainbrighton commented 4 years ago

Ah - that's my mistake - I missed committing one file 😭, Hopefully, it'll be OK now...

it-praktyk commented 4 years ago

Good job!

Tests Passed: 1080, Failed: 0, Skipped: 0, Pending: 0, Inconclusive: 0 
iainbrighton commented 4 years ago

Thanks for your help/assist!

it-praktyk commented 4 years ago

Can you consider releasing the current version to the PowerShell Gallery too?

iainbrighton commented 4 years ago

Hi Wojciech - I'll release it soon. I'd like to get some feedback from @tpcarman that I haven't broken anything too badly with all the code refactoring first!

tpcarman commented 4 years ago

My quick testing of the dev branch on PS 5.1, I get the following error with Word output Exception calling "Save" with "1" argument(s): "Unable to determine the identity of domain.". Other outputs appear to work OK. I will investigate further to see if I can isolate the issue. FYI, 0.7.26 does not produce the error.

iainbrighton commented 4 years ago

Isn’t that error due to the size of the resulting .docx file being bigger than x? I don’t think the latest version should be generating significantly different document sizes to previous versions (not that I’ve checked)..

tpcarman commented 4 years ago

I'm still testing this, however using the exact same environment and parameters, I have no issues with 0.7.26, but get the error using the dev branch.