test/sandbox: invoke check program directly
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Fpkg (push) Successful in 34s
Test / Fortify (push) Successful in 40s
Test / Data race detector (push) Successful in 2m47s
Test / Flake checks (push) Successful in 1m4s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-03-27 03:09:16 +09:00
parent 300571af47
commit 996b42634d
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
5 changed files with 18 additions and 19 deletions

View File

@ -6,7 +6,12 @@
}: }:
let let
testCases = import ./sandbox/case { testCases = import ./sandbox/case {
inherit (pkgs) lib callPackage foot; inherit (pkgs)
lib
callPackage
writeText
foot
;
inherit (config.environment.fortify.package) version; inherit (config.environment.fortify.package) version;
}; };
in in

View File

@ -34,10 +34,13 @@ type T struct {
MountsPath string MountsPath string
} }
func (t *T) MustCheckFile(wantFilePath string) { func (t *T) MustCheckFile(wantFilePath, markerPath string) {
var want *TestCase var want *TestCase
mustDecode(wantFilePath, &want) mustDecode(wantFilePath, &want)
t.MustCheck(want) t.MustCheck(want)
if _, err := os.Create(markerPath); err != nil {
fatalf("cannot create success marker: %v", err)
}
} }
func (t *T) MustCheck(want *TestCase) { func (t *T) MustCheck(want *TestCase) {

View File

@ -24,7 +24,7 @@ buildGoModule {
import "os" import "os"
import "git.gensokyo.uk/security/fortify/test/sandbox" import "git.gensokyo.uk/security/fortify/test/sandbox"
func main() { (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1]) } func main() { (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1], "/tmp/sandbox-ok") }
''} main.go ''} main.go
''; '';
} }

View File

@ -1,6 +1,7 @@
{ {
lib, lib,
callPackage, callPackage,
writeText,
foot, foot,
version, version,
@ -29,7 +30,7 @@ let
; ;
}; };
checkSandbox = callPackage ../. { inherit version; }; checkSandbox = callPackage ../assert.nix { inherit version; };
callTestCase = callTestCase =
path: path:
@ -48,7 +49,11 @@ let
inherit (tc) tty mapRealUid; inherit (tc) tty mapRealUid;
share = foot; share = foot;
packages = [ ]; packages = [ ];
command = builtins.toString (checkSandbox tc.name tc.want); path = "${checkSandbox}/bin/test";
args = [
"test"
(toString (writeText "fortify-${tc.name}-want.json" (builtins.toJSON tc.want)))
];
}; };
in in
{ {

View File

@ -1,14 +0,0 @@
{
writeShellScript,
writeText,
callPackage,
version,
}:
name: want:
writeShellScript "fortify-${name}-check-sandbox-script" ''
set -e
${callPackage ./assert.nix { inherit version; }}/bin/test \
${writeText "fortify-${name}-want.json" (builtins.toJSON want)}
touch /tmp/sandbox-ok
''