test/sandbox: invoke check program directly
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
300571af47
commit
996b42634d
@ -6,7 +6,12 @@
|
||||
}:
|
||||
let
|
||||
testCases = import ./sandbox/case {
|
||||
inherit (pkgs) lib callPackage foot;
|
||||
inherit (pkgs)
|
||||
lib
|
||||
callPackage
|
||||
writeText
|
||||
foot
|
||||
;
|
||||
inherit (config.environment.fortify.package) version;
|
||||
};
|
||||
in
|
||||
|
@ -34,10 +34,13 @@ type T struct {
|
||||
MountsPath string
|
||||
}
|
||||
|
||||
func (t *T) MustCheckFile(wantFilePath string) {
|
||||
func (t *T) MustCheckFile(wantFilePath, markerPath string) {
|
||||
var want *TestCase
|
||||
mustDecode(wantFilePath, &want)
|
||||
t.MustCheck(want)
|
||||
if _, err := os.Create(markerPath); err != nil {
|
||||
fatalf("cannot create success marker: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *T) MustCheck(want *TestCase) {
|
||||
|
@ -24,7 +24,7 @@ buildGoModule {
|
||||
import "os"
|
||||
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
|
||||
'';
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
lib,
|
||||
callPackage,
|
||||
writeText,
|
||||
foot,
|
||||
|
||||
version,
|
||||
@ -29,7 +30,7 @@ let
|
||||
;
|
||||
};
|
||||
|
||||
checkSandbox = callPackage ../. { inherit version; };
|
||||
checkSandbox = callPackage ../assert.nix { inherit version; };
|
||||
|
||||
callTestCase =
|
||||
path:
|
||||
@ -48,7 +49,11 @@ let
|
||||
inherit (tc) tty mapRealUid;
|
||||
share = foot;
|
||||
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
|
||||
{
|
||||
|
@ -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
|
||||
''
|
Loading…
Reference in New Issue
Block a user