mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Add test for external-builders
This commit is contained in:
parent
584ef0ffd3
commit
73e4c40e64
2 changed files with 51 additions and 0 deletions
50
tests/functional/external-builders.sh
Normal file
50
tests/functional/external-builders.sh
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
TODO_NixOS
|
||||||
|
|
||||||
|
needLocalStore "'--external-builders' can’t be used with the daemon"
|
||||||
|
|
||||||
|
expr="$TEST_ROOT/expr.nix"
|
||||||
|
cat > "$expr" <<EOF
|
||||||
|
with import ${config_nix};
|
||||||
|
mkDerivation {
|
||||||
|
name = "external";
|
||||||
|
system = "x68_46-xunil";
|
||||||
|
buildCommand = ''
|
||||||
|
echo xyzzy
|
||||||
|
printf foo > \$out
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
external_builder="$TEST_ROOT/external-builder.sh"
|
||||||
|
cat > "$external_builder" <<EOF
|
||||||
|
#! $SHELL -e
|
||||||
|
|
||||||
|
PATH=$PATH
|
||||||
|
|
||||||
|
[[ "\$1" = bla ]]
|
||||||
|
|
||||||
|
system="\$(jq -r .system < "\$2")"
|
||||||
|
builder="\$(jq -r .builder < "\$2")"
|
||||||
|
args="\$(jq -r '.args | join(" ")' < "\$2")"
|
||||||
|
export buildCommand="\$(jq -r .env.buildCommand < "\$2")"
|
||||||
|
export out="\$(jq -r .env.out < "\$2")"
|
||||||
|
[[ \$system = x68_46-xunil ]]
|
||||||
|
|
||||||
|
printf "\2\n"
|
||||||
|
|
||||||
|
# In a real external builder, we would now call something like qemu to emulate the system.
|
||||||
|
"\$builder" \$args
|
||||||
|
|
||||||
|
printf bar >> \$out
|
||||||
|
EOF
|
||||||
|
chmod +x "$external_builder"
|
||||||
|
|
||||||
|
nix build -L --file "$expr" --out-link "$TEST_ROOT/result" \
|
||||||
|
--extra-experimental-features external-builders \
|
||||||
|
--external-builders "[{\"systems\": [\"x68_46-xunil\"], \"args\": [\"bla\"], \"program\": \"$external_builder\"}]"
|
||||||
|
|
||||||
|
[[ $(cat "$TEST_ROOT/result") = foobar ]]
|
||||||
|
|
@ -174,6 +174,7 @@ suites = [
|
||||||
'extra-sandbox-profile.sh',
|
'extra-sandbox-profile.sh',
|
||||||
'help.sh',
|
'help.sh',
|
||||||
'symlinks.sh',
|
'symlinks.sh',
|
||||||
|
'external-builders.sh',
|
||||||
],
|
],
|
||||||
'workdir' : meson.current_source_dir(),
|
'workdir' : meson.current_source_dir(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue