Optimize fetch-git.
This commit is contained in:
@ -8,7 +8,7 @@ use Hydra::Helper::AddBuilds;
|
||||
use Cwd;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(hydra_setup nrBuildsForJobset queuedBuildsForJobset nrQueuedBuildsForJobset createBaseJobset createJobsetWithOneInput evalSucceeds runBuild);
|
||||
our @EXPORT = qw(hydra_setup nrBuildsForJobset queuedBuildsForJobset nrQueuedBuildsForJobset createBaseJobset createJobsetWithOneInput evalSucceeds runBuild updateRepository);
|
||||
|
||||
sub hydra_setup {
|
||||
my ($db) = @_;
|
||||
@ -74,4 +74,12 @@ sub runBuild {
|
||||
return captureStdoutStderr(60, ("../src/script/hydra-build", $build->id));
|
||||
}
|
||||
|
||||
sub updateRepository {
|
||||
my ($scm, $update, $repo) = @_;
|
||||
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ($update, $repo));
|
||||
die "Unexpected update error with $scm: $stderr\n" unless $res;
|
||||
print STDOUT "Update $scm repository: $stdout" if $stdout ne "";
|
||||
return $stdout ne "";
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -7,7 +7,7 @@ use Setup;
|
||||
|
||||
my $db = Hydra::Model::DB->new;
|
||||
|
||||
use Test::Simple tests => 28;
|
||||
use Test::Simple tests => 48;
|
||||
|
||||
hydra_setup($db);
|
||||
|
||||
@ -57,7 +57,17 @@ my @scminputs = ("svn", "svn-checkout", "git", "bzr", "bzr-checkout", "hg");
|
||||
foreach my $scm (@scminputs) {
|
||||
$jobset = createJobsetWithOneInput($scm, "$scm-input.nix", "src", $scm, "$jobsBaseUri/$scm-repo");
|
||||
|
||||
ok(evalSucceeds($jobset), "Evaluating jobs/$scm-input.nix should exit with return code 0.");
|
||||
ok(nrQueuedBuildsForJobset($jobset) == 1, "Evaluating jobs/$scm-input.nix should result in 1 build in queue");
|
||||
}
|
||||
my $c = 1;
|
||||
my $q = 1;
|
||||
do {
|
||||
# Verify that it can be fetched and queued.
|
||||
ok(evalSucceeds($jobset), "$c Evaluating jobs/$scm-input.nix should exit with return code 0."); $c++;
|
||||
ok(nrQueuedBuildsForJobset($jobset) == $q, "$c Evaluating jobs/$scm-input.nix should result in 1 build in queue"); $c++;
|
||||
|
||||
# Verify that it is deterministic and not queued again.
|
||||
ok(evalSucceeds($jobset), "$c Evaluating jobs/$scm-input.nix should exit with return code 0."); $c++;
|
||||
ok(nrQueuedBuildsForJobset($jobset) == $q, "$c Evaluating jobs/$scm-input.nix should result in $q build in queue"); $c++;
|
||||
|
||||
$q++;
|
||||
} while(updateRepository($scm, getcwd . "/jobs/$scm-update.sh", getcwd . "/$scm-repo/"));
|
||||
}
|
||||
|
1
tests/jobs/bzr-checkout-update.sh
Executable file
1
tests/jobs/bzr-checkout-update.sh
Executable file
@ -0,0 +1 @@
|
||||
#! /bin/sh
|
1
tests/jobs/bzr-update.sh
Executable file
1
tests/jobs/bzr-update.sh
Executable file
@ -0,0 +1 @@
|
||||
#! /bin/sh
|
26
tests/jobs/git-update.sh
Executable file
26
tests/jobs/git-update.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#! /bin/sh
|
||||
|
||||
cd "$1"
|
||||
STATE_FILE=.state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(0)
|
||||
echo "Add new file."
|
||||
touch git-file-2
|
||||
git add git-file-2 >&2
|
||||
git commit -m "add git file 2" git-file-2 >&2
|
||||
;;
|
||||
(1)
|
||||
echo "Rewrite commit."
|
||||
echo 1 > git-file-2
|
||||
git add git-file-2 >&2
|
||||
git commit --amend -m "add git file 2" git-file-2 >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
1
tests/jobs/hg-update.sh
Executable file
1
tests/jobs/hg-update.sh
Executable file
@ -0,0 +1 @@
|
||||
#! /bin/sh
|
1
tests/jobs/svn-checkout-update.sh
Executable file
1
tests/jobs/svn-checkout-update.sh
Executable file
@ -0,0 +1 @@
|
||||
#! /bin/sh
|
1
tests/jobs/svn-update.sh
Executable file
1
tests/jobs/svn-update.sh
Executable file
@ -0,0 +1 @@
|
||||
#! /bin/sh
|
Reference in New Issue
Block a user