forked from lix-project/hydra
Merge pull request #9 from nbp/deep-clone-check
Add tests for "git describe --long".
This commit is contained in:
commit
c1653a9561
|
@ -33,7 +33,7 @@ check_SCRIPTS = db.sqlite repos
|
|||
db.sqlite : $(top_srcdir)/src/sql/hydra-sqlite.sql
|
||||
$(TESTS_ENVIRONMENT) $(top_srcdir)/src/script/hydra-init
|
||||
|
||||
repos : dirs git-repo hg-repo svn-repo svn-checkout-repo bzr-repo bzr-checkout-repo
|
||||
repos : dirs
|
||||
|
||||
dirs :
|
||||
mkdir -p data
|
||||
|
@ -43,34 +43,3 @@ dirs :
|
|||
touch nix/etc/nix/nix.conf
|
||||
mkdir -p nix/store
|
||||
mkdir -p nix/var
|
||||
|
||||
git-repo :
|
||||
git init git-repo
|
||||
touch git-repo/git-file
|
||||
(cd git-repo; git add git-file ; git commit -m "add git file" git-file)
|
||||
|
||||
hg-repo :
|
||||
hg init hg-repo
|
||||
touch hg-repo/hg-file
|
||||
(cd hg-repo; hg add hg-file ; hg commit -m "add hg file" hg-file -u foobar)
|
||||
|
||||
svn-repo :
|
||||
svnadmin create svn-repo
|
||||
svn co file://$(abs_builddir)/svn-repo svn-checkout
|
||||
touch svn-checkout/svn-file
|
||||
svn add svn-checkout/svn-file
|
||||
svn commit -m "add svn file" svn-checkout/svn-file
|
||||
|
||||
bzr-repo :
|
||||
bzr init bzr-repo
|
||||
BZR_HOME=$(abs_builddir)/data bzr whoami "build <build@donotemail.com>" -d bzr-repo
|
||||
touch bzr-repo/bzr-file
|
||||
bzr add bzr-repo/bzr-file
|
||||
BZR_HOME=$(abs_builddir)/data bzr commit -m "add bzr-file" bzr-repo/bzr-file
|
||||
|
||||
svn-checkout-repo :
|
||||
ln -s svn-repo svn-checkout-repo
|
||||
|
||||
bzr-checkout-repo :
|
||||
ln -s bzr-repo bzr-checkout-repo
|
||||
|
||||
|
|
|
@ -75,11 +75,12 @@ sub runBuild {
|
|||
}
|
||||
|
||||
sub updateRepository {
|
||||
my ($scm, $update, $repo) = @_;
|
||||
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ($update, $repo));
|
||||
my ($scm, $update) = @_;
|
||||
my ($res, $stdout, $stderr) = captureStdoutStderr(60, ($update, $scm));
|
||||
die "Unexpected update error with $scm: $stderr\n" unless $res;
|
||||
print STDOUT "Update $scm repository: $stdout" if $stdout ne "";
|
||||
return $stdout ne "";
|
||||
my ($message, $loop, $status) = $stdout =~ m/::(.*) -- (.*) -- (.*)::/;
|
||||
print STDOUT "Update $scm repository: $message\n";
|
||||
return ($loop eq "continue", $status eq "updated");
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -7,7 +7,7 @@ use Setup;
|
|||
|
||||
my $db = Hydra::Model::DB->new;
|
||||
|
||||
use Test::Simple tests => 48;
|
||||
use Test::Simple tests => 60;
|
||||
|
||||
hydra_setup($db);
|
||||
|
||||
|
@ -53,21 +53,86 @@ for my $build (queuedBuildsForJobset($jobset)) {
|
|||
|
||||
|
||||
# Test scm inputs
|
||||
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");
|
||||
my @scminputs = (
|
||||
{
|
||||
name => "svn",
|
||||
nixexpr => "svn-input.nix",
|
||||
type => "svn",
|
||||
uri => "$jobsBaseUri/svn-repo",
|
||||
update => getcwd . "/jobs/svn-update.sh"
|
||||
},
|
||||
{
|
||||
name => "svn-checkout",
|
||||
nixexpr => "svn-checkout-input.nix",
|
||||
type => "svn-checkout",
|
||||
uri => "$jobsBaseUri/svn-checkout-repo",
|
||||
update => getcwd . "/jobs/svn-checkout-update.sh"
|
||||
},
|
||||
{
|
||||
name => "git",
|
||||
nixexpr => "git-input.nix",
|
||||
type => "git",
|
||||
uri => "$jobsBaseUri/git-repo",
|
||||
update => getcwd . "/jobs/git-update.sh"
|
||||
},
|
||||
{
|
||||
name => "deepgit",
|
||||
nixexpr => "deepgit-input.nix",
|
||||
type => "git",
|
||||
uri => "$jobsBaseUri/git-repo master 1",
|
||||
update => getcwd . "/jobs/git-update.sh"
|
||||
},
|
||||
{
|
||||
name => "bzr",
|
||||
nixexpr => "bzr-input.nix",
|
||||
type => "bzr",
|
||||
uri => "$jobsBaseUri/bzr-repo",
|
||||
update => getcwd . "/jobs/bzr-update.sh"
|
||||
},
|
||||
{
|
||||
name => "bzr-checkout",
|
||||
nixexpr => "bzr-checkout-input.nix",
|
||||
type => "bzr-checkout",
|
||||
uri => "$jobsBaseUri/bzr-checkout-repo",
|
||||
update => getcwd . "/jobs/bzr-checkout-update.sh"
|
||||
},
|
||||
{
|
||||
name => "hg",
|
||||
nixexpr => "hg-input.nix",
|
||||
type => "hg",
|
||||
uri => "$jobsBaseUri/hg-repo",
|
||||
update => getcwd . "/jobs/hg-update.sh"
|
||||
}
|
||||
);
|
||||
|
||||
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++;
|
||||
foreach my $scm ( @scminputs ) {
|
||||
my $scmName = $scm->{"name"};
|
||||
my $nixexpr = $scm->{"nixexpr"};
|
||||
my $type = $scm->{"type"};
|
||||
my $uri = $scm->{"uri"};
|
||||
my $update = $scm->{"update"};
|
||||
$jobset = createJobsetWithOneInput($scmName, $nixexpr, "src", $type, $uri);
|
||||
|
||||
# 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++;
|
||||
my $state = 0;
|
||||
my $q = 0;
|
||||
my ($loop, $updated) = updateRepository($scmName, $update);
|
||||
while($loop) {
|
||||
my $c = 0;
|
||||
|
||||
$q++;
|
||||
} while(updateRepository($scm, getcwd . "/jobs/$scm-update.sh", getcwd . "/$scm-repo/"));
|
||||
# Verify that it can be fetched and possibly queued.
|
||||
ok(evalSucceeds($jobset), "$scmName:$state.$c: Evaluating nix-expression."); $c++;
|
||||
|
||||
# Verify that the evaluation has queued a new job and evaluate again to ...
|
||||
if ($updated) {
|
||||
$q++;
|
||||
ok(nrQueuedBuildsForJobset($jobset) == $q, "$scmName:$state.$c: Expect $q jobs in the queue."); $c++;
|
||||
ok(evalSucceeds($jobset), "$scmName:$state.$c: Evaluating nix-expression again."); $c++;
|
||||
}
|
||||
|
||||
# ... check that it is deterministic and not queued again.
|
||||
ok(nrQueuedBuildsForJobset($jobset) == $q, "$scmName:$state.$c: Expect $q jobs in the queue."); $c++;
|
||||
|
||||
$state++;
|
||||
($loop, $updated) = updateRepository($scmName, $update, getcwd . "/$scmName-repo/");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,19 @@
|
|||
#! /bin/sh
|
||||
|
||||
repo="$1"
|
||||
STATE_FILE=$(pwd)/.bzr-checkout-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 1 && state=0
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
ln -s bzr-repo bzr-checkout-repo
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::" ;;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
||||
|
|
|
@ -1 +1,24 @@
|
|||
#! /bin/sh
|
||||
|
||||
repo="$1"
|
||||
STATE_FILE=$(pwd)/.bzr-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 1 && state=0
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
export BZR_HOME; # Set by the Makefile
|
||||
case $state in
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
bzr init bzr-repo
|
||||
bzr whoami "build <build@donotemail.com>" -d bzr-repo
|
||||
touch bzr-repo/bzr-file
|
||||
bzr add bzr-repo/bzr-file
|
||||
bzr commit -m "add bzr-file" bzr-repo/bzr-file
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::";;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
||||
|
|
6
tests/jobs/deepgit-builder.sh
Normal file
6
tests/jobs/deepgit-builder.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
mkdir $out
|
||||
cp -v $src/* $out/
|
||||
git describe --long > $out/Version
|
10
tests/jobs/deepgit-input.nix
Normal file
10
tests/jobs/deepgit-input.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
with import ./config.nix;
|
||||
{ src }:
|
||||
{
|
||||
copy =
|
||||
mkDerivation {
|
||||
name = "git-input";
|
||||
builder = ./scm-builder.sh;
|
||||
inherit src;
|
||||
};
|
||||
}
|
|
@ -1,25 +1,49 @@
|
|||
#! /bin/sh
|
||||
# This script is used both by git & deepgit checks.
|
||||
|
||||
cd "$1"
|
||||
STATE_FILE=.state
|
||||
repo=git-repo
|
||||
STATE_FILE=$(pwd)/.git-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 3 && state=0
|
||||
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
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
git init $repo
|
||||
cd $repo
|
||||
touch foo
|
||||
git add foo
|
||||
git commit -m "Add foo"
|
||||
git tag -a -m "First Tag." tag0
|
||||
git checkout -b master HEAD
|
||||
;;
|
||||
(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
|
||||
(1) echo "::Create new commit. -- continue -- updated::"
|
||||
cd $repo
|
||||
# Increase depth to make sure the tag is not fetched by default.
|
||||
echo 0 > foo
|
||||
git add foo
|
||||
git commit -m "Increase depth 0"
|
||||
echo 1 > foo
|
||||
git add foo
|
||||
git commit -m "Increase depth 1"
|
||||
echo 2 > foo
|
||||
git add foo
|
||||
git commit -m "Increase depth 2"
|
||||
echo 0 > bar
|
||||
git add bar
|
||||
git commit -m "Add bar with 0"
|
||||
;;
|
||||
(2) echo "::Amend commit. (push -f) -- continue -- updated::"
|
||||
cd $repo
|
||||
echo 1 > bar
|
||||
git add bar
|
||||
git commit --amend -m "Add bar with 1"
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::"
|
||||
rm -rf $repo
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -1 +1,23 @@
|
|||
#! /bin/sh
|
||||
|
||||
repo="$1"
|
||||
STATE_FILE=$(pwd)/.hg-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 1 && state=0
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
hg init hg-repo
|
||||
touch hg-repo/hg-file
|
||||
cd hg-repo
|
||||
hg add hg-file
|
||||
hg commit -m "add hg file" hg-file -u foobar
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::" ;;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
||||
|
|
|
@ -1 +1,19 @@
|
|||
#! /bin/sh
|
||||
|
||||
repo="$1"
|
||||
STATE_FILE=$(pwd)/.svn-checkout-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 1 && state=0
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
ln -s svn-repo svn-checkout-repo
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::" ;;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
||||
|
|
|
@ -1 +1,23 @@
|
|||
#! /bin/sh
|
||||
|
||||
repo="$1"
|
||||
STATE_FILE=$(pwd)/.svn-state
|
||||
if test -e $STATE_FILE; then
|
||||
state=$(cat $STATE_FILE)
|
||||
test $state -gt 1 && state=0
|
||||
else
|
||||
state=0;
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(0) echo "::Create repo. -- continue -- updated::"
|
||||
svnadmin create svn-repo
|
||||
svn co $repo svn-checkout
|
||||
touch svn-checkout/svn-file
|
||||
svn add svn-checkout/svn-file
|
||||
svn commit -m "add svn file" svn-checkout/svn-file
|
||||
;;
|
||||
(*) echo "::End. -- stop -- nothing::";;
|
||||
esac
|
||||
|
||||
echo $(($state + 1)) > $STATE_FILE
|
||||
|
|
Loading…
Reference in a new issue