forked from puppetlabs/puppetlabs-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(MODULES-8358) Add PowerShell Session Manager for pwsh
Previously the pwsh provider would save a file to a temporary location and then execute that. This is considered a legacy method. The more modern method, which is used in the Windows PowerShell provider, is to use the PowerShell Manager. This commit updates the PowerShell Manager for using PowerShell Core on both Windows and non-Windows platforms: * The pwsh provider was modified to use the PowerShell manager if it is supported otherwise revert to the legacy temporary path * The pwsh provider changed the scope of the pwsh_args and get_pwsh_command to public so that they can be used the spec tests. As they're readonly properties it is safe to surface these methods * Modified the PowerShell manager to use Unix Domain Sockets when on non-Windows platforms. This is due to the .Net implmentation of the NamedPipesClient class using Domain Sockets on non-Windows platforms as opposed to Named Pipes. [1] [2] [3] The manager creates the domain sockets in the user's tmp directrory This also means the errors returned on bad/failed pipes is different e.g. EOFError and EConnReset. Also many of the integration tests assume a real named pipe, so these tests are guarded to only run on Windows. Note that it was not possible to replicate the "delete named pipe" using Unix Domain sockets due to how sockets are different to named pipes. * Modified many of the tests to either be platform independent by either removing the platform specific things e.g. remove \r\n references or specific exit codes. Or the tests are modified to use specific items on specific platforms e.g. cmd.exe on Windows and /bin/sh on non-Windows. * Removed the use of aliases (e.g. ps and ls) as they were causing test failures as they behave differently on different platforms. Instead prefer commands like Get-Verb or $PSVersionTable which are consistent. * Moved the 'when specifying a working directory' test from unit to integration as it actually calls the operating system for information and was causing failures when pwsh was not installed * Modified the PowerShell Manager integration tests to be a shared example group and can then simply use 'it_behaves_like' calls to test when appropriate. This is important on non-Windows when pwsh isn't installed. * Modified the unit tests for the pwsh provider to use a mocked PowerShell Manager when invoked. [1] https://github.com/dotnet/corefx/blob/94e9d02ad70b2224d012ac4a66eaa1f913ae4f29/src/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs#L49-L60 [2] https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs#L44 [3] https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs#L298-L299
- Loading branch information
1 parent
9f11091
commit cca8fae
Showing
6 changed files
with
317 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.