From 09668545907f10b839e1fc5d8ccc5dda6876da03 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 5 Jan 2011 14:04:38 +0000 Subject: [PATCH] * Use makeWrapper in building the test driver. * In the interactive test driver, provide a function "testScript" to run the non-interactive test script. svn path=/nixos/trunk/; revision=25426 --- lib/test-driver/test-driver.pl | 16 ++++++++++++---- lib/testing.nix | 15 +++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index 6735b52dd695..362572205242 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -1,19 +1,19 @@ -#! @perl@ -w -I@libDir@ -I@readline@ +#! /somewhere/perl use strict; use Machine; use Term::ReadLine; +use IO::File; +use XML::Writer; $SIG{PIPE} = 'IGNORE'; # because Unix domain sockets may die unexpectedly -$ENV{PATH} = "@extraPath@:$ENV{PATH}"; - STDERR->autoflush(1); + my %vms; my $context = ""; - foreach my $vmScript (@ARGV) { my $vm = Machine->new({startCommand => $vmScript}); $vms{$vm->name} = $vm; @@ -26,6 +26,14 @@ sub startAll { } +# In interactive tests, this allows the non-interactive test script to +# be executed conveniently. +sub testScript { + eval "$context $ENV{testScript};\n"; + warn $@ if $@; +} + + sub runTests { if (defined $ENV{tests}) { eval "$context $ENV{tests}"; diff --git a/lib/testing.nix b/lib/testing.nix index 3cf0bc5bf407..46ca9954ccde 100644 --- a/lib/testing.nix +++ b/lib/testing.nix @@ -10,7 +10,12 @@ rec { testDriver = stdenv.mkDerivation { name = "nixos-test-driver"; - buildCommand = + + buildInputs = [ makeWrapper perl ]; + + unpackPhase = "true"; + + installPhase = '' mkdir -p $out/bin cp ${./test-driver/test-driver.pl} $out/bin/nixos-test-driver @@ -20,11 +25,9 @@ rec { mkdir -p $libDir cp ${./test-driver/Machine.pm} $libDir/Machine.pm - substituteInPlace $out/bin/nixos-test-driver \ - --subst-var-by perl "${perl}/bin/perl" \ - --subst-var-by readline "${perlPackages.TermReadLineGnu}/lib/perl5/site_perl" \ - --subst-var-by extraPath "${imagemagick}/bin" \ - --subst-var libDir + wrapProgram $out/bin/nixos-test-driver \ + --prefix PATH : "${imagemagick}/bin" \ + --prefix PERL5LIB : "${lib.makePerlPath [ perlPackages.TermReadLineGnu perlPackages.XMLWriter ]}:$out/lib/perl5/site_perl" ''; };