summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authornzbr <mail@nzbr.de>2023-01-17 19:46:54 +0100
committernzbr <mail@nzbr.de>2023-01-17 19:46:54 +0100
commitca81ce0df217a7e70da54b72b1af7dc76a6a4bfe (patch)
treea5571d844e7d3c5cfe72e8934e9e28e7b6e3afd0 /tests
parent217178edb1127fb41ac4fd534d8a513c3dd3d81b (diff)
fix powershell test
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/lib.ps112
-rw-r--r--tests/shells.Tests.ps12
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
}
}