diff options
| author | nzbr <mail@nzbr.de> | 2023-01-17 19:46:54 +0100 |
|---|---|---|
| committer | nzbr <mail@nzbr.de> | 2023-01-17 19:46:54 +0100 |
| commit | ca81ce0df217a7e70da54b72b1af7dc76a6a4bfe (patch) | |
| tree | a5571d844e7d3c5cfe72e8934e9e28e7b6e3afd0 /tests | |
| parent | 217178edb1127fb41ac4fd534d8a513c3dd3d81b (diff) | |
fix powershell test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lib/lib.ps1 | 12 | ||||
| -rw-r--r-- | tests/shells.Tests.ps1 | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/lib/lib.ps1 b/tests/lib/lib.ps1 index beef272..bc2dd94 100644 --- a/tests/lib/lib.ps1 +++ b/tests/lib/lib.ps1 @@ -2,6 +2,16 @@ if ($PSVersionTable.PSEdition -ne 'Core') { throw "The tests are not compatible with Windows PowerShell, please use PowerShell Core instead" } +function Remove-Escapes { + param( + [parameter(ValueFromPipeline = $true)] + [string[]]$InputObject + ) + process { + $InputObject | ForEach-Object { $_ -replace '\x1b(\[(\?..|.)|.)', '' } + } +} + # Implementation-independent base class class Distro { [string]$id @@ -155,9 +165,11 @@ class WslDistro : Distro { # Auto-select the implementation to use function Install-Distro() { if ($IsWindows) { + Write-Host "Detected Windows host, using WSL" return [WslDistro]::new() } else { + Write-Host "Detected Linux host, using Docker" return [DockerDistro]::new() } } diff --git a/tests/shells.Tests.ps1 b/tests/shells.Tests.ps1 index fda3295..4dae61b 100644 --- a/tests/shells.Tests.ps1 +++ b/tests/shells.Tests.ps1 @@ -18,7 +18,7 @@ users.users.`${config.wsl.defaultUser}.shell = pkgs.$package; "@ > $temp $distro.InstallConfig($temp) Remove-Item $temp - $distro.Launch("echo `$SHELL") | Select-Object -Last 1 | Should -BeExactly "/run/current-system/sw/bin/$executable" + $distro.Launch("echo `$SHELL") | Remove-Escapes | Select-Object -Last 1 | Should -BeExactly "/run/current-system/sw/bin/$executable" $LASTEXITCODE | Should -Be 0 } } |
