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YVD2DWQC
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
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");
# 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");
# Test scm inputs
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/");
}
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
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
#! /bin/sh
set -e
mkdir $out
cp -v $src/* $out/
git describe --long > $out/Version
with import ./config.nix;
{ src }:
{
copy =
mkDerivation {
name = "git-input";
builder = ./scm-builder.sh;
inherit src;
};
}
(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"
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
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
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