nix: go generate in src derivation
All checks were successful
Test / Sandbox (push) Successful in 40s
Test / Fortify (race detector) (push) Successful in 49s
Test / Fortify (push) Successful in 50s
Test / Create distribution (push) Successful in 24s
Test / Sandbox (race detector) (push) Successful in 45s
Test / Fpkg (push) Successful in 39s
Test / Flake checks (push) Successful in 1m12s

This saves the generated files in the nix store and exposes them for use by external tools.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-06-07 03:10:36 +09:00
parent b7e991de5b
commit 9a7c81a44e
3 changed files with 38 additions and 20 deletions

View File

@@ -31,14 +31,13 @@ nixosTest {
{
environment.systemPackages = [
# For go tests:
(writeShellScriptBin "fortify-go-test" ''
set -e
WORK="$(mktemp -ud)"
cp -r "${self.packages.${system}.fortify.src}" "$WORK"
chmod -R +w "$WORK"
cd "$WORK"
(writeShellScriptBin "fortify-test" ''
cd ${self.packages.${system}.fortify.src}
${fhs}/bin/fortify-fhs -c \
'go generate ./... && go test ${if withRace then "-race" else "-count 16"} ./... && touch /tmp/go-test-ok'
'go test ${if withRace then "-race" else "-count 16"} ./...' \
&> /tmp/fortify-test.log && \
touch /tmp/fortify-test-ok
touch /tmp/fortify-test-done
'')
];

View File

@@ -80,9 +80,6 @@ def fortify(command):
start_all()
machine.wait_for_unit("multi-user.target")
# Run fortify Go tests outside of nix build in the background:
machine.succeed("sudo -u untrusted -i fortify-go-test &> /tmp/go-test &")
# To check fortify's version:
print(machine.succeed("sudo -u alice -i fortify version"))
@@ -90,6 +87,9 @@ print(machine.succeed("sudo -u alice -i fortify version"))
machine.wait_for_file("/run/user/1000/wayland-1")
machine.wait_for_file("/tmp/sway-ipc.sock")
# Run fortify Go tests outside of nix build in the background:
swaymsg("exec fortify-test")
# Deny unmapped uid:
denyOutput = machine.fail("sudo -u untrusted -i fortify run &>/dev/stdout")
print(denyOutput)
@@ -255,6 +255,6 @@ machine.wait_for_file("/tmp/sway-exit-ok")
print(machine.succeed("find /run/user/1000/fortify"))
# Verify go test status:
machine.wait_for_file("/tmp/go-test", timeout=5)
print(machine.succeed("cat /tmp/go-test"))
machine.wait_for_file("/tmp/go-test-ok", timeout=5)
machine.wait_for_file("/tmp/fortify-test-done")
print(machine.succeed("cat /tmp/fortify-test.log"))
machine.wait_for_file("/tmp/fortify-test-ok", timeout=2)