input-types.t: don't litter ./tests/

This commit is contained in:
Graham Christensen 2021-02-23 21:42:59 -05:00
parent 611d7b71f2
commit cccdc70162
No known key found for this signature in database
GPG key ID: FE918C3A98C1030F
2 changed files with 19 additions and 13 deletions

View file

@ -12,7 +12,10 @@ use Test2::V0;
my $db = Hydra::Model::DB->new; my $db = Hydra::Model::DB->new;
hydra_setup($db); hydra_setup($db);
my $jobsBaseUri = "file://".getcwd; my $testdir = getcwd;
my $scratchdir = "$datadir/scratch";
mkdir $scratchdir;
my $jobsBaseUri = "file://".$scratchdir;
# Test scm inputs # Test scm inputs
my @scminputs = ( my @scminputs = (
@ -21,63 +24,63 @@ my @scminputs = (
nixexpr => "svn-input.nix", nixexpr => "svn-input.nix",
type => "svn", type => "svn",
uri => "$jobsBaseUri/svn-repo", uri => "$jobsBaseUri/svn-repo",
update => getcwd . "/jobs/svn-update.sh" update => $testdir . "/jobs/svn-update.sh"
}, },
{ {
name => "svn-checkout", name => "svn-checkout",
nixexpr => "svn-checkout-input.nix", nixexpr => "svn-checkout-input.nix",
type => "svn-checkout", type => "svn-checkout",
uri => "$jobsBaseUri/svn-checkout-repo", uri => "$jobsBaseUri/svn-checkout-repo",
update => getcwd . "/jobs/svn-checkout-update.sh" update => $testdir . "/jobs/svn-checkout-update.sh"
}, },
{ {
name => "git", name => "git",
nixexpr => "git-input.nix", nixexpr => "git-input.nix",
type => "git", type => "git",
uri => "$jobsBaseUri/git-repo", uri => "$jobsBaseUri/git-repo",
update => getcwd . "/jobs/git-update.sh" update => $testdir . "/jobs/git-update.sh"
}, },
{ {
name => "git-rev", name => "git-rev",
nixexpr => "git-rev-input.nix", nixexpr => "git-rev-input.nix",
type => "git", type => "git",
uri => "$jobsBaseUri/git-repo 7f60df502b96fd54bbfa64dd94b56d936a407701", uri => "$jobsBaseUri/git-repo 7f60df502b96fd54bbfa64dd94b56d936a407701",
update => getcwd . "/jobs/git-rev-update.sh" update => $testdir . "/jobs/git-rev-update.sh"
}, },
{ {
name => "deepgit", name => "deepgit",
nixexpr => "deepgit-input.nix", nixexpr => "deepgit-input.nix",
type => "git", type => "git",
uri => "$jobsBaseUri/git-repo master 1", uri => "$jobsBaseUri/git-repo master 1",
update => getcwd . "/jobs/git-update.sh" update => $testdir . "/jobs/git-update.sh"
}, },
{ {
name => "bzr", name => "bzr",
nixexpr => "bzr-input.nix", nixexpr => "bzr-input.nix",
type => "bzr", type => "bzr",
uri => "$jobsBaseUri/bzr-repo", uri => "$jobsBaseUri/bzr-repo",
update => getcwd . "/jobs/bzr-update.sh" update => $testdir . "/jobs/bzr-update.sh"
}, },
{ {
name => "bzr-checkout", name => "bzr-checkout",
nixexpr => "bzr-checkout-input.nix", nixexpr => "bzr-checkout-input.nix",
type => "bzr-checkout", type => "bzr-checkout",
uri => "$jobsBaseUri/bzr-checkout-repo", uri => "$jobsBaseUri/bzr-checkout-repo",
update => getcwd . "/jobs/bzr-checkout-update.sh" update => $testdir . "/jobs/bzr-checkout-update.sh"
}, },
{ {
name => "hg", name => "hg",
nixexpr => "hg-input.nix", nixexpr => "hg-input.nix",
type => "hg", type => "hg",
uri => "$jobsBaseUri/hg-repo", uri => "$jobsBaseUri/hg-repo",
update => getcwd . "/jobs/hg-update.sh" update => $testdir . "/jobs/hg-update.sh"
}, },
{ {
name => "darcs", name => "darcs",
nixexpr => "darcs-input.nix", nixexpr => "darcs-input.nix",
type => "darcs", type => "darcs",
uri => "$jobsBaseUri/darcs-repo", uri => "$jobsBaseUri/darcs-repo",
update => getcwd . "/jobs/darcs-update.sh" update => $testdir . "/jobs/darcs-update.sh"
} }
); );
@ -93,7 +96,7 @@ foreach my $scm ( @scminputs ) {
my $state = 0; my $state = 0;
my $q = 0; my $q = 0;
my ($loop, $updated) = updateRepository($scmName, $update); my ($loop, $updated) = updateRepository($scmName, $update, $scratchdir);
while($loop) { while($loop) {
subtest "Mutation number $state" => sub { subtest "Mutation number $state" => sub {
# Verify that it can be fetched and possibly queued. # Verify that it can be fetched and possibly queued.
@ -110,7 +113,7 @@ foreach my $scm ( @scminputs ) {
is(nrQueuedBuildsForJobset($jobset), $q, "Expect deterministic evaluation."); is(nrQueuedBuildsForJobset($jobset), $q, "Expect deterministic evaluation.");
$state++; $state++;
($loop, $updated) = updateRepository($scmName, $update, getcwd . "/$scmName-repo/"); ($loop, $updated) = updateRepository($scmName, $update, $scratchdir);
}; };
} }
}; };

View file

@ -115,8 +115,11 @@ sub runBuild {
} }
sub updateRepository { sub updateRepository {
my ($scm, $update) = @_; my ($scm, $update, $scratchdir) = @_;
my $curdir = getcwd;
chdir "$scratchdir";
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ($update, $scm)); my ($res, $stdout, $stderr) = captureStdoutStderr(60, ($update, $scm));
chdir "$curdir";
die "unexpected update error with $scm: $stderr\n" if $res; die "unexpected update error with $scm: $stderr\n" if $res;
my ($message, $loop, $status) = $stdout =~ m/::(.*) -- (.*) -- (.*)::/; my ($message, $loop, $status) = $stdout =~ m/::(.*) -- (.*) -- (.*)::/;
print STDOUT "Update $scm repository: $message\n"; print STDOUT "Update $scm repository: $message\n";