Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e73ec02c8 | |||
| c3cf0f67ee |
2 changed files with 26 additions and 4 deletions
|
|
@ -62,7 +62,7 @@
|
||||||
export HTTPS_PROXY=http://127.0.0.1:7000
|
export HTTPS_PROXY=http://127.0.0.1:7000
|
||||||
export NO_PROXY=localhost,127.0.0.1
|
export NO_PROXY=localhost,127.0.0.1
|
||||||
|
|
||||||
trap "${pkgs.coreutils}/bin/kill $HTTP_SOCAT_PID" EXIT
|
trap "${pkgs.coreutils}/bin/kill $HTTP_SOCAT_PID || true" EXIT
|
||||||
|
|
||||||
${command pkgs} "$@"
|
${command pkgs} "$@"
|
||||||
'';
|
'';
|
||||||
|
|
@ -145,14 +145,14 @@
|
||||||
${pkgs.socat}/bin/socat UNIX-LISTEN:"$JD/net.sock",fork TCP:127.0.0.1:"$FREE_PORT" &>/dev/null &
|
${pkgs.socat}/bin/socat UNIX-LISTEN:"$JD/net.sock",fork TCP:127.0.0.1:"$FREE_PORT" &>/dev/null &
|
||||||
SOCAT_PID=$!
|
SOCAT_PID=$!
|
||||||
|
|
||||||
trap "${pkgs.coreutils}/bin/rm -rf $JD; ${pkgs.coreutils}/bin/kill $PROXY_PID $SOCAT_PID" EXIT
|
trap "${pkgs.coreutils}/bin/rm -rf $JD; ${pkgs.coreutils}/bin/kill $PROXY_PID $SOCAT_PID || true" EXIT
|
||||||
|
|
||||||
export NIX_CONFIG="
|
export NIX_CONFIG="
|
||||||
''${NIX_CONFIG:-}
|
''${NIX_CONFIG:-}
|
||||||
extra-experimental-features = nix-command flakes
|
extra-experimental-features = nix-command flakes
|
||||||
substitute = true"
|
substitute = true"
|
||||||
|
|
||||||
${jailed}/bin/unsafe-cell
|
${jailed}/bin/unsafe-cell "$@"
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
host-script
|
host-script
|
||||||
|
|
|
||||||
24
tests.nix
24
tests.nix
|
|
@ -19,6 +19,7 @@ nixpkgs.lib.genAttrs
|
||||||
logDir ? "$JD",
|
logDir ? "$JD",
|
||||||
worktreePath,
|
worktreePath,
|
||||||
nixDaemonSocket ? "/var/nix/daemon-socket",
|
nixDaemonSocket ? "/var/nix/daemon-socket",
|
||||||
|
extraArgs ? "",
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cell = unsafe-cell.lib.mkCell.${system} {
|
cell = unsafe-cell.lib.mkCell.${system} {
|
||||||
|
|
@ -38,7 +39,7 @@ nixpkgs.lib.genAttrs
|
||||||
export HOME=$(pwd)
|
export HOME=$(pwd)
|
||||||
export LANG=C
|
export LANG=C
|
||||||
mkdir ./cell
|
mkdir ./cell
|
||||||
${cell}
|
${cell} ${extraArgs}
|
||||||
touch $out
|
touch $out
|
||||||
echo ":: test passed: ${name}"
|
echo ":: test passed: ${name}"
|
||||||
'';
|
'';
|
||||||
|
|
@ -379,6 +380,27 @@ nixpkgs.lib.genAttrs
|
||||||
echo "ok 1 - extra combinator env var propagated"
|
echo "ok 1 - extra combinator env var propagated"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# CLI arguments forwarded into the jail
|
||||||
|
cli-args = mkJailTest "cli-args" {
|
||||||
|
worktreePath = "./cell";
|
||||||
|
extraArgs = "foo bar baz";
|
||||||
|
command =
|
||||||
|
pkgs:
|
||||||
|
pkgs.writeScript "cli-args" ''
|
||||||
|
set -euo pipefail
|
||||||
|
[ "$1" = "foo" ]
|
||||||
|
echo "ok 2 - first arg is foo"
|
||||||
|
|
||||||
|
[ "$2" = "bar" ]
|
||||||
|
echo "ok 3 - second arg is bar"
|
||||||
|
|
||||||
|
[ "$3" = "baz" ]
|
||||||
|
echo "ok 4 - third arg is baz"
|
||||||
|
|
||||||
|
echo "PASS: CLI arguments forwarded correctly"
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
allTests = builtins.attrValues tests;
|
allTests = builtins.attrValues tests;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue