Test RemoteStore::buildDerivation

Fix `wopNarFromPath` which needed a `toRealPath`.
This commit is contained in:
John Ericson 2020-08-12 13:24:39 +00:00
parent 5d67f18c86
commit d2f2be0f70
3 changed files with 30 additions and 7 deletions

View file

@ -688,7 +688,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto path = store->parseStorePath(readString(from)); auto path = store->parseStorePath(readString(from));
logger->startWork(); logger->startWork();
logger->stopWork(); logger->stopWork();
dumpPath(store->printStorePath(path), to); dumpPath(store->toRealPath(store->printStorePath(path)), to);
break; break;
} }

View file

@ -26,6 +26,16 @@ let
requiredSystemFeatures = ["bar"]; requiredSystemFeatures = ["bar"];
}; };
input3 = mkDerivation {
shell = busybox;
name = "build-remote-input-3";
buildCommand = ''
read x < ${input2}
echo $x BAZ > $out
'';
requiredSystemFeatures = ["baz"];
};
in in
mkDerivation { mkDerivation {
@ -34,7 +44,7 @@ in
buildCommand = buildCommand =
'' ''
read x < ${input1} read x < ${input1}
read y < ${input2} read y < ${input3}
echo "$x $y" > $out echo "$x $y" > $out
''; '';
} }

View file

@ -13,6 +13,7 @@ builders=(
# remote-store URL. # remote-store URL.
"ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=foo - - 1 1 foo" "ssh://localhost?remote-store=$TEST_ROOT/machine1?system-features=foo - - 1 1 foo"
"$TEST_ROOT/machine2 - - 1 1 bar" "$TEST_ROOT/machine2 - - 1 1 bar"
"ssh-ng://localhost?remote-store=$TEST_ROOT/machine3?system-features=baz - - 1 1 baz"
) )
# Note: ssh://localhost bypasses ssh, directly invoking nix-store as a # Note: ssh://localhost bypasses ssh, directly invoking nix-store as a
@ -25,12 +26,24 @@ nix build -L -v -f build-hook.nix -o $TEST_ROOT/result --max-jobs 0 \
outPath=$(readlink -f $TEST_ROOT/result) outPath=$(readlink -f $TEST_ROOT/result)
grep 'FOO BAR' $TEST_ROOT/machine0/$outPath grep 'FOO BAR BAZ' $TEST_ROOT/machine0/$outPath
set -o pipefail
# Ensure that input1 was built on store1 due to the required feature. # Ensure that input1 was built on store1 due to the required feature.
(! nix path-info --store $TEST_ROOT/machine2 --all | grep builder-build-remote-input-1.sh) nix path-info --store $TEST_ROOT/machine1 --all \
nix path-info --store $TEST_ROOT/machine1 --all | grep builder-build-remote-input-1.sh | grep builder-build-remote-input-1.sh \
| grep -v builder-build-remote-input-2.sh \
| grep -v builder-build-remote-input-3.sh
# Ensure that input2 was built on store2 due to the required feature. # Ensure that input2 was built on store2 due to the required feature.
(! nix path-info --store $TEST_ROOT/machine1 --all | grep builder-build-remote-input-2.sh) nix path-info --store $TEST_ROOT/machine2 --all \
nix path-info --store $TEST_ROOT/machine2 --all | grep builder-build-remote-input-2.sh | grep -v builder-build-remote-input-1.sh \
| grep builder-build-remote-input-2.sh \
| grep -v builder-build-remote-input-3.sh
# Ensure that input3 was built on store3 due to the required feature.
nix path-info --store $TEST_ROOT/machine3 --all \
| grep -v builder-build-remote-input-1.sh \
| grep -v builder-build-remote-input-2.sh \
| grep builder-build-remote-input-3.sh