From 75baee8523f62b75a0cf350a8360ce8f3e3c3695 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 8 Sep 2016 15:34:04 +0200 Subject: [PATCH] runInMachine: Support passAsFile We need to rewrite attributes passed via files to their location in /tmp/xchg in the VM. Otherwise functions like runCommand don't work. --- nixos/lib/testing.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 61b214bfba8..b177146a56b 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -157,9 +157,7 @@ rec { ${coreutils}/bin/mkdir -p $TMPDIR cd $TMPDIR - $origBuilder $origArgs - - exit $? + exec $origBuilder $origArgs ''; testScript = '' @@ -172,9 +170,20 @@ rec { ''; vmRunCommand = writeText "vm-run" '' + xchg=vm-state-client/xchg ${coreutils}/bin/mkdir $out - ${coreutils}/bin/mkdir -p vm-state-client/xchg - export > vm-state-client/xchg/saved-env + ${coreutils}/bin/mkdir -p $xchg + + for i in $passAsFile; do + i2=''${i}Path + _basename=$(${coreutils}/bin/basename ''${!i2}) + ${coreutils}/bin/cp ''${!i2} $xchg/$_basename + eval $i2=/tmp/xchg/$_basename + ${coreutils}/bin/ls -la $xchg + done + unset i i2 _basename + + export > $xchg/saved-env export tests='${testScript}' ${testDriver}/bin/nixos-test-driver ${vm.config.system.build.vm}/bin/run-*-vm ''; # */