summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/enumerate-tests29
-rwxr-xr-xtests/http-static-server96
-rw-r--r--tests/lib29
-rw-r--r--tests/lib-gdr12
-rwxr-xr-xtests/setup/examplegit4
-rwxr-xr-xtests/setup/http-git-check15
-rwxr-xr-xtests/tests/alternating-dgit25
-rwxr-xr-xtests/tests/clone-gitnosuite2
-rwxr-xr-xtests/tests/clone-nogit2
-rwxr-xr-xtests/tests/forcesplit-overwrite3
-rwxr-xr-xtests/tests/ftpmasterapi-http19
-rwxr-xr-xtests/tests/gdr-import-dgit1
12 files changed, 214 insertions, 23 deletions
diff --git a/tests/enumerate-tests b/tests/enumerate-tests
index 8ee34be..680236e 100755
--- a/tests/enumerate-tests
+++ b/tests/enumerate-tests
@@ -45,18 +45,27 @@ test-begin-gencontrol () {
dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, faketime'
}
+gencontrol-add-things () {
+ local varname=$1; shift
+ local delim=$1; shift
+ local thing
+ eval '
+ for thing in "$@"; do
+ case " $'$varname$delim '" in
+ *" "$thing"'$delim' "*) continue ;;
+ esac
+ '$varname'+="${'$varname':+'$delim' }$thing"
+ done
+ '
+}
+
restriction-gencontrol () {
if [ $r = x-dgit-out-of-tree-only ]; then return; fi
- restrictions+=" $r"
+ gencontrol-add-things restrictions '' "$r"
}
gencontrol-add-deps () {
- for dep in "$@"; do
- case " $dependencies," in
- *" "$dep","*) continue ;;
- esac
- dependencies+="${dependencies:+, }$dep"
- done
+ gencontrol-add-things dependencies , "$@"
}
dependencies-gencontrol () {
@@ -89,7 +98,7 @@ test-done-gencontrol () {
}
'
case "$restrictions" in
- ?*) echo "Restrictions:$restrictions" ;;
+ ?*) echo "Restrictions: $restrictions" ;;
esac
)
key=$(printf "%s" "$stanza" | sha256sum)
@@ -132,6 +141,10 @@ allsedderies () {
for import in $(seddery 's/^t-setup-import //p'); do
allsedderies tests/setup/$import
done
+ if egrep -q '^t-alt-test *$' <$tf; then
+ local leaf=${tf#tests/tests/}
+ allsedderies tests/tests/"${leaf#*-}"
+ fi
}
for t in $(run-parts --list tests/tests); do
diff --git a/tests/http-static-server b/tests/http-static-server
new file mode 100755
index 0000000..f2f7cd0
--- /dev/null
+++ b/tests/http-static-server
@@ -0,0 +1,96 @@
+#!/usr/bin/perl -w
+#
+# This file is part of the dgit test suite.
+#
+# Copyright (C)2004-2015 Best Practical Solutions, LLC
+# Copyright (C)2019 Ian Jackson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+#
+# invocation protocol:
+#
+# http-static-server >port-file tests/tmp/$thing/aq
+#
+# Will write the allocated port number to port-file.
+# Then we fork and the parent exits 0.
+# If port-file is unlinked, we exit.
+
+use strict;
+use IO::Handle;
+
+our ($webroot) = @ARGV;
+our $port = '';
+
+# HTTP::Server::Simple handles requests in the main process so it
+# must redirect and close STDOUT. So transplant STDOUT to CHECK.
+open CHECK, ">& STDOUT" or die $!;
+open STDOUT, ">/dev/null" or die $!;
+
+sub stat_type_check () {
+ die "[$port, $webroot] stdout not ta plain file"
+ unless -f _;
+}
+
+stat CHECK or die $!;
+stat_type_check();
+
+sub start_polling_fstat () {
+ our $polling_pid = $$;
+ $SIG{ALRM} = sub {
+ return unless $$ = $polling_pid;
+ stat CHECK or die $!;
+ my $nlink = (stat _)[3];
+ exit 0 unless $nlink;
+ stat_type_check(); # doesn't seem possible to fail but check anyway
+ alarm(1);
+ };
+ alarm(1);
+}
+
+package ServerClass;
+
+use strict;
+use Socket qw(AF_INET SOCK_STREAM);
+use Socket qw(AF_INET SOCK_STREAM unpack_sockaddr_in);
+use IO::Handle;
+
+use base qw(HTTP::Server::Simple::CGI);
+use HTTP::Server::Simple::Static;
+
+sub handle_request {
+ my ($self, $cgi) = @_;
+
+ if (!$self->serve_static($cgi, $::webroot)) {
+ print "HTTP/1.0 404 Not found\r\n";
+ print $cgi->header,
+ $cgi->start_html('Not found'),
+ $cgi->h1('Not found'),
+ $cgi->end_html;
+ }
+}
+
+sub port () { return 0; }
+
+sub after_setup_listener () {
+ my $sn = getsockname HTTP::Server::Simple::HTTPDaemon or die $!;
+ ($main::port,) = unpack_sockaddr_in $sn;
+ print main::CHECK $port, "\n" or die $!;
+ flush main::CHECK or die $!;
+ my $c = fork // die $!;
+ exit 0 if $c;
+ ::main::start_polling_fstat();
+}
+
+package main;
+
+our $server = ServerClass->new();
+$server->run();
diff --git a/tests/lib b/tests/lib
index 78ec9a7..8392e79 100644
--- a/tests/lib
+++ b/tests/lib
@@ -22,7 +22,14 @@ END
exit 16
}
-trap 'test $? = 0 || t-report-failure' EXIT
+trap '
+ rc=$?
+ set +e
+ [ "x$DGIT_TEST_KEEP_MUSTCLEAN" != x ] || \
+ [ "x$DGIT_TEST_TMP" = x ] || rm -rf $DGIT_TEST_TMP/must-clean
+ set -e
+ test $rc = 0 || t-report-failure
+' EXIT
t-filter-out-git-hyphen-dir
@@ -74,6 +81,11 @@ export DEBCHANGE_VENDOR=dpkg
unset VISUAL
unset GIT_EDITOR
+mkdir -p $tmp/must-clean
+# must-clean is usually removed after each test, on success or failure.
+# But this must not be relied on for correctness, only for garbage
+# collection etc.
+
mkdir -p $tmp/incoming
cat <<END >$tmp/dput.cf
[test-dummy]
@@ -464,6 +476,19 @@ t-dgit () {
'
}
+t-non-dgit-upload () {
+ t-dgit -wgf build-source
+
+ cd ..
+ c=${p}_${v}_source.changes
+ debsign -kBCD22CD83243B79D3DFAC33EA3DBCBC039B13D8A $c
+ dput -c $tmp/dput.cf test-dummy $c
+
+ t-archive-process-incoming sid
+ t-git-next-date
+ cd $p
+}
+
t-dgit-manpage () {
local section=$1
local page=$2
@@ -573,6 +598,8 @@ t-setup-import () {
(set -e; cd $tmp; tar xf "$simport.tar")
fi
+ mkdir -p $tmp/must-clean
+
. "$simport"
}
diff --git a/tests/lib-gdr b/tests/lib-gdr
index cda11df..bf94fba 100644
--- a/tests/lib-gdr
+++ b/tests/lib-gdr
@@ -260,17 +260,7 @@ t-nmu-upload-2 () {
t-nmu-upload-3 () {
t-dch-commit-r
-
- t-dgit -wgf build-source
-
- cd ..
- c=${p}_${v}_source.changes
- debsign -kBCD22CD83243B79D3DFAC33EA3DBCBC039B13D8A $c
- dput -c $tmp/dput.cf test-dummy $c
-
- t-archive-process-incoming sid
- t-git-next-date
- cd $p
+ t-non-dgit-upload
git checkout master
}
diff --git a/tests/setup/examplegit b/tests/setup/examplegit
index 88f6178..d25ee95 100755
--- a/tests/setup/examplegit
+++ b/tests/setup/examplegit
@@ -50,4 +50,6 @@ push-to master sid
git clean -xdff
-t-setup-done 'p v suitespecs majorv revision' "aq git mirror $p"
+t-setup-done 'v suitespecs majorv revision' "aq git mirror $p" "
+ t-select-package $p
+"
diff --git a/tests/setup/http-git-check b/tests/setup/http-git-check
new file mode 100755
index 0000000..0e3b7c2
--- /dev/null
+++ b/tests/setup/http-git-check
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-dependencies libhttp-server-simple-static-perl
+
+t-setup-done '' --files-from=/dev/null '
+ $troot/http-static-server >$tmp/must-clean/git-check.port $tmp/git
+ read <$tmp/must-clean/git-check.port git_check_port
+
+ t-git-config --global dgit-distro.test-dummy.git-check url
+ t-git-config --global dgit-distro.test-dummy.git-check-suffix .git/HEAD
+ t-git-config --global dgit-distro.test-dummy.git-check-url \
+ http://127.0.0.1:$git_check_port
+'
diff --git a/tests/tests/alternating-dgit b/tests/tests/alternating-dgit
new file mode 100755
index 0000000..c2ada5c
--- /dev/null
+++ b/tests/tests/alternating-dgit
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-setup-import examplegit
+t-setup-import http-git-check
+
+cd $p
+
+git checkout -b nondgit
+t-commit 'non-dgit upload'
+t-non-dgit-upload
+
+cd ..
+
+t-dgit clone $p ./$p.2
+cd $p.2
+
+t-commit 'now a dgit upload again'
+
+t-dgit -wgf push-source
+t-refs-same-start
+t-pushed-good dgit/sid
+
+t-ok
diff --git a/tests/tests/clone-gitnosuite b/tests/tests/clone-gitnosuite
index 83c996d..b85efdb 100755
--- a/tests/tests/clone-gitnosuite
+++ b/tests/tests/clone-gitnosuite
@@ -2,6 +2,8 @@
set -e
. tests/lib
+t-setup-import http-git-check
+
t-archive pari-extra 3-1
t-git-none
cp -a $tmp/git/_template $dgitrepo
diff --git a/tests/tests/clone-nogit b/tests/tests/clone-nogit
index e99dac3..f36a7b6 100755
--- a/tests/tests/clone-nogit
+++ b/tests/tests/clone-nogit
@@ -2,6 +2,8 @@
set -e
. tests/lib
+t-setup-import http-git-check
+
t-archive pari-extra 3-1
t-git-none
diff --git a/tests/tests/forcesplit-overwrite b/tests/tests/forcesplit-overwrite
index 9600d3a..5826287 100755
--- a/tests/tests/forcesplit-overwrite
+++ b/tests/tests/forcesplit-overwrite
@@ -7,8 +7,7 @@ set -e
t-setup-import examplegit
-t-select-package example
-cd example
+cd $p
suite=stable
diff --git a/tests/tests/ftpmasterapi-http b/tests/tests/ftpmasterapi-http
new file mode 100755
index 0000000..818a974
--- /dev/null
+++ b/tests/tests/ftpmasterapi-http
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-archive-none example
+
+t-dependencies libhttp-server-simple-static-perl
+
+$troot/http-static-server >$tmp/must-clean/api.port $tmp/aq
+
+read <$tmp/must-clean/api.port api_port
+
+t-git-config --global dgit-distro.test-dummy.archive-query ftpmasterapi:
+t-git-config --global dgit-distro.test-dummy.archive-query-url \
+ http://127.0.0.1:$api_port/
+
+t-dgit archive-api-query suites
+
+t-ok
diff --git a/tests/tests/gdr-import-dgit b/tests/tests/gdr-import-dgit
index e58ff32..1050f72 100755
--- a/tests/tests/gdr-import-dgit
+++ b/tests/tests/gdr-import-dgit
@@ -6,6 +6,7 @@ t-dependencies GDR
t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
+t-setup-import http-git-check
cd $p