Skip to content

Commit

Permalink
use wsl --install
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Dec 27, 2024
1 parent 6d5d06b commit fb80e8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- name: Setup WSL 🐧
run: |
wsl --update
wsl --update --pre-release
wsl --version
- name: Execute Test 🧪
Expand Down
10 changes: 3 additions & 7 deletions tests/lib/lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ function Remove-Escapes {
# Implementation-independent base class
class Distro {
[string]$id
[string]$tempdir

Distro() {
$tarball = $this.FindTarball()

$this.id = $(New-Guid).ToString()
$this.tempdir = Join-Path $([System.IO.Path]::GetTempPath()) $this.id
New-Item -ItemType Directory $this.tempdir

& wsl.exe --import $this.id $this.tempdir $tarball --version 2 | Write-Host
$install = "wsl.exe --install --from-file $tarball --name $($this.id)"
Write-Host "> $install"
Invoke-Expression $install | Write-Host
if ($LASTEXITCODE -ne 0) {
throw "Failed to import distro"
}
Expand Down Expand Up @@ -82,8 +81,5 @@ class Distro {
if ($LASTEXITCODE -ne 0) {
throw "Failed to unregister distro"
}
if (Test-Path $this.tempdir) {
Remove-Item $this.tempdir -Recurse -Force
}
}
}

0 comments on commit fb80e8d

Please sign in to comment.