test: run go test under regular user
All checks were successful
Test / Create distribution (push) Successful in 24s
Test / Fpkg (push) Successful in 32s
Test / Fortify (push) Successful in 2m16s
Test / Data race detector (push) Successful in 2m46s
Test / Flake checks (push) Successful in 54s

By default test vm commands run as root, this causes buildFHSEnv bwrap to cover some parts of /proc, making it impossible to mount proc in a mount namespace created under it. Running as a regular user gets around this issue.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-03-13 20:56:32 +09:00
parent 2871426df2
commit beb3918809
2 changed files with 13 additions and 7 deletions

View File

@@ -15,8 +15,15 @@ nixosTest {
{
environment.systemPackages = [
# For go tests:
self.packages.${system}.fhs
(writeShellScriptBin "fortify-src" "echo -n ${self.packages.${system}.fortify.src}")
(writeShellScriptBin "fortify-go-test" ''
set -e
WORK="$(mktemp -ud)"
cp -r "${self.packages.${system}.fortify.src}" "$WORK"
chmod -R +w "$WORK"
cd "$WORK"
${self.packages.${system}.fhs}/bin/fortify-fhs -c \
'go generate ./... && go test ./... && touch /tmp/go-test-ok'
'')
];
# Run with Go race detector: