Skip to content

Commit e58c9f4

Browse files
committed
add test for envfs
1 parent 146e7c5 commit e58c9f4

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

tests/envfs/envfs.Tests.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
BeforeAll {
2+
. $PSScriptRoot/../lib/lib.ps1
3+
}
4+
5+
Describe "envfs" {
6+
BeforeAll {
7+
$distro = [Distro]::new()
8+
}
9+
10+
It "should install" {
11+
$distro.InstallConfig("$PSScriptRoot/envfs.nix", "switch")
12+
}
13+
14+
It "should not break the distro" {
15+
$distro.Launch("true")
16+
$LASTEXITCODE | Should -Be 0
17+
}
18+
19+
It "should allow running scripts with #!/bin/python3 instead of #!/usr/bin/env python3" {
20+
$distro.Launch("echo '#!/bin/python3' > ~/test.py")
21+
$LASTEXITCODE | Should -Be 0
22+
23+
$distro.Launch("echo print(`"hello`") >> ~/test.py")
24+
$LASTEXITCODE | Should -Be 0
25+
26+
$distro.Launch("chmod +x ~/test.py")
27+
$LASTEXITCODE | Should -Be 0
28+
29+
$output = $distro.Launch("~/test.py") | Select-Object -Last 1
30+
$output | Should -BeExactly "hello"
31+
$LASTEXITCODE | Should -Be 0
32+
}
33+
34+
AfterAll {
35+
$distro.Uninstall()
36+
}
37+
}

tests/envfs/envfs.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{ lib, pkgs, ... }:
2+
with lib; {
3+
imports = [
4+
<nixos-wsl/modules>
5+
];
6+
7+
config = {
8+
wsl.enable = true;
9+
services.envfs.enable = true;
10+
11+
environment.systemPackages = [
12+
pkgs.python3
13+
];
14+
};
15+
}

0 commit comments

Comments
 (0)