* 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
This commit is contained in:
Eelco Dolstra 2011-01-05 14:04:38 +00:00
parent c8bca42355
commit 0966854590
2 changed files with 21 additions and 10 deletions

View File

@ -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}";

View File

@ -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"
'';
};