windows tests: convert test script into fixed-output derivation

pull/16/head
Astro 2019-04-13 23:59:22 +02:00 committed by Sébastien Bourdeauducq
parent ac89dfeb70
commit f3fca76dd6
1 changed files with 31 additions and 8 deletions

View File

@ -8,6 +8,25 @@
with pkgs; with pkgs;
let let
artiqSrc = <artiqSrc>;
artiqVersion =
pkgs.runCommand "artiq-version" {
buildInputs = [ pkgs.nix pkgs.git ];
} ''
REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
echo \"5e.`cut -c1-8 <<< $REV`\" > $out
'';
generateTestOkHash =
pkgs.runCommand "generate-test-ok-hash" {
buildInputs = [ pkgs.nix ];
} ''
TMPDIR=`mktemp -d`
cp ${artiqVersion} $TMPDIR/passed
HASH=`nix-hash --type sha256 --base32 $TMPDIR`
echo \"$HASH\" > $out
'';
qemu = import ./qemu.nix { qemu = import ./qemu.nix {
inherit pkgs qemuMem; inherit pkgs qemuMem;
diskImage = "c.img"; diskImage = "c.img";
@ -18,14 +37,15 @@ let
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = "windows-test-conda-artiq"; name = "windows-test-conda-artiq";
src = ./.;
dontBuild = true; outputHashAlgo = "sha256";
installPhase = '' outputHashMode = "recursive";
mkdir $out outputHash = import generateTestOkHash;
''; __hydraRetry = false;
doCheck = true;
checkInputs = qemu.inputs; phases = [ "buildPhase" ];
checkPhase = '' buildInputs = qemu.inputs;
buildPhase = ''
# +1 day from last modification of the disk image # +1 day from last modification of the disk image
CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400)) CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400))
${qemu.runQemu [ ${qemu.runQemu [
@ -52,5 +72,8 @@ in
${ssh "shutdown -a"} ${ssh "shutdown -a"}
# Power off immediately # Power off immediately
${ssh "shutdown -p -f"} ${ssh "shutdown -p -f"}
mkdir $out
cp ${artiqVersion} $out/passed
''; '';
} }