test/sandbox: separate test tool source
This improves readability and allows gofmt to format the file. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
a102178019
commit
d97a03c7c6
@ -5,15 +5,7 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
testCases = import ./sandbox/case {
|
testCases = import ./sandbox/case pkgs config.environment.fortify.package.version;
|
||||||
inherit (pkgs)
|
|
||||||
lib
|
|
||||||
callPackage
|
|
||||||
writeText
|
|
||||||
foot
|
|
||||||
;
|
|
||||||
inherit (config.environment.fortify.package) version;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
users.users = {
|
users.users = {
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
writeText,
|
|
||||||
buildGoModule,
|
|
||||||
pkg-config,
|
|
||||||
util-linux,
|
|
||||||
|
|
||||||
version,
|
|
||||||
}:
|
|
||||||
buildGoModule {
|
|
||||||
pname = "check-sandbox";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = ../.;
|
|
||||||
vendorHash = null;
|
|
||||||
|
|
||||||
buildInputs = [ util-linux ];
|
|
||||||
nativeBuildInputs = [ pkg-config ];
|
|
||||||
|
|
||||||
preBuild = ''
|
|
||||||
go mod init git.gensokyo.uk/security/fortify/test >& /dev/null
|
|
||||||
cp ${writeText "main.go" ''
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
import "git.gensokyo.uk/security/fortify/test/sandbox"
|
|
||||||
|
|
||||||
func main() { (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1], "/tmp/sandbox-ok") }
|
|
||||||
''} main.go
|
|
||||||
'';
|
|
||||||
}
|
|
@ -1,12 +1,14 @@
|
|||||||
{
|
pkgs: version:
|
||||||
lib,
|
|
||||||
callPackage,
|
|
||||||
writeText,
|
|
||||||
foot,
|
|
||||||
|
|
||||||
version,
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
|
inherit (pkgs)
|
||||||
|
lib
|
||||||
|
writeText
|
||||||
|
buildGoModule
|
||||||
|
pkg-config
|
||||||
|
util-linux
|
||||||
|
foot
|
||||||
|
;
|
||||||
|
|
||||||
fs = mode: dir: data: {
|
fs = mode: dir: data: {
|
||||||
mode = lib.fromHexString mode;
|
mode = lib.fromHexString mode;
|
||||||
inherit
|
inherit
|
||||||
@ -30,7 +32,21 @@ let
|
|||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
checkSandbox = callPackage ../assert.nix { inherit version; };
|
checkSandbox = buildGoModule {
|
||||||
|
pname = "check-sandbox";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = ../../.;
|
||||||
|
vendorHash = null;
|
||||||
|
|
||||||
|
buildInputs = [ util-linux ];
|
||||||
|
nativeBuildInputs = [ pkg-config ];
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
go mod init git.gensokyo.uk/security/fortify/test >& /dev/null
|
||||||
|
cp ${./main.go} main.go
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
callTestCase =
|
callTestCase =
|
||||||
path:
|
path:
|
||||||
|
9
test/sandbox/case/main.go
Normal file
9
test/sandbox/case/main.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"git.gensokyo.uk/security/fortify/test/sandbox"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() { (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1], "/tmp/sandbox-ok") }
|
Loading…
Reference in New Issue
Block a user