[debsums] 01/01: Add a small test suite for debsums
Axel Beckert
abe at deuxchevaux.org
Wed Mar 25 21:45:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to branch master
in repository debsums.
commit 8d7eb5081c24e2f835c808bc2d8f7b98ae93fd5a
Author: Axel Beckert <abe at deuxchevaux.org>
Date: Wed Mar 25 21:55:38 2015 +0100
Add a small test suite for debsums
Includes a minimal test environment and a test file running some
common debsums commands.
Use override_dh_auto_test for now to run it.
---
debian/changelog | 1 +
debian/rules | 3 ++
t/debsums.t | 44 +++++++++++++++++++++
t/fakechroot/usr/share/doc/fakepkg/README | 1 +
.../usr/share/doc/fakepkg/changelog.Debian.gz | Bin 0 -> 161 bytes
t/fakechroot/usr/share/doc/fakepkg/copyright | 14 +++++++
t/fakechroot/var/lib/dpkg/info/fakepkg.list | 3 ++
t/fakechroot/var/lib/dpkg/info/fakepkg.md5sums | 3 ++
t/fakechroot/var/lib/dpkg/status | 10 +++++
t/fakechroot/var/lib/dpkg/updates/.emptydir | 0
10 files changed, 79 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 2f1b49d..e4af500 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,7 @@ debsums (2.1~dev) UNRELEASED; urgency=medium
+ Whitespace cleanup.
+ Exit with highest exit code of any of its child debsums processes
exited. (Closes: #711560)
+ * Add simple test suite
[ Andreas Beckmann ]
* Fix accessing files in the host root filesystem (/) while checking an
diff --git a/debian/rules b/debian/rules
index 92a2130..4338967 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,5 +12,8 @@ override_dh_auto_install:
override_dh_auto_clean:
cd man && po4a --no-translations --rm-backups po4a.cfg
+override_dh_auto_test:
+ prove -v
+
override_dh_installman:
dh_installman `find man -type f -name '*.[18]'`
diff --git a/t/debsums.t b/t/debsums.t
new file mode 100644
index 0000000..3dfa84b
--- /dev/null
+++ b/t/debsums.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -T
+
+# Simple test for running debsums on a fake chroot
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Command::Simple;
+
+# Default dummy chroot as test bed
+my $chroot_option = '--root=t/fakechroot';
+
+# Untaint stuff
+delete $ENV{PATH};
+
+# First check if we are testing a source package (debsums in current
+# directory) or an installed package (full path).
+my $command;
+foreach my $cmd (qw(./debsums /usr/bin/debsums)) {
+ $command = $cmd if -x $cmd;
+}
+ok($command, "Command debsums found at $command");
+my @command = ($command, $chroot_option);
+
+# Test running without any further parameters
+run(@command);
+is(stderr, '', 'STDERR is empty');
+is(stdout, <<'EOT', 'STDOUT as expected (2 OK, 1 FAILED)');
+t/fakechroot/usr/share/doc/fakepkg/copyright OK
+t/fakechroot/usr/share/doc/fakepkg/changelog.Debian.gz OK
+t/fakechroot/usr/share/doc/fakepkg/README FAILED
+EOT
+is(rc >> 8, 2, 'Exit code is 2');
+
+# Test option -c
+run(@command, '-c');
+is(stderr, '', 'STDERR is empty');
+is(stdout, <<'EOT', 'STDOUT as expected (1 FAILED)');
+t/fakechroot/usr/share/doc/fakepkg/README
+EOT
+is(rc >> 8, 2, 'Exit code is 2');
+
+done_testing();
diff --git a/t/fakechroot/usr/share/doc/fakepkg/README b/t/fakechroot/usr/share/doc/fakepkg/README
new file mode 100644
index 0000000..753abf0
--- /dev/null
+++ b/t/fakechroot/usr/share/doc/fakepkg/README
@@ -0,0 +1 @@
+This file should be reported as FAIL by debsums
diff --git a/t/fakechroot/usr/share/doc/fakepkg/changelog.Debian.gz b/t/fakechroot/usr/share/doc/fakepkg/changelog.Debian.gz
new file mode 100644
index 0000000..bdbec22
Binary files /dev/null and b/t/fakechroot/usr/share/doc/fakepkg/changelog.Debian.gz differ
diff --git a/t/fakechroot/usr/share/doc/fakepkg/copyright b/t/fakechroot/usr/share/doc/fakepkg/copyright
new file mode 100644
index 0000000..ecf2c92
--- /dev/null
+++ b/t/fakechroot/usr/share/doc/fakepkg/copyright
@@ -0,0 +1,14 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Comment: This is a fake copyright file, part of debsums' test suite
+
+Files: *
+Copyright:
+ 2015 Axel Beckert <abe at debian.org>
+License: GPL
+ This is free software, licensed under the terms of the GNU General Public
+ License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE.
+ .
+ You are free to distribute this software under the terms of the GNU General
+ Public License. On Debian systems, the complete text of the GNU General
+ Public License can be found in /usr/share/common-licenses/GPL file.
diff --git a/t/fakechroot/var/lib/dpkg/info/fakepkg.list b/t/fakechroot/var/lib/dpkg/info/fakepkg.list
new file mode 100644
index 0000000..8b3cf25
--- /dev/null
+++ b/t/fakechroot/var/lib/dpkg/info/fakepkg.list
@@ -0,0 +1,3 @@
+/usr/share/doc/fakepkg/copyright
+/usr/share/doc/fakepkg/changelog.Debian.gz
+/usr/share/doc/fakepkg/README
diff --git a/t/fakechroot/var/lib/dpkg/info/fakepkg.md5sums b/t/fakechroot/var/lib/dpkg/info/fakepkg.md5sums
new file mode 100644
index 0000000..492102e
--- /dev/null
+++ b/t/fakechroot/var/lib/dpkg/info/fakepkg.md5sums
@@ -0,0 +1,3 @@
+52f02364e60d4865543a2e935533ef33 usr/share/doc/fakepkg/copyright
+082797d51b0c32d421e274b05926618a usr/share/doc/fakepkg/changelog.Debian.gz
+deadbeefcafebabedeadbeefcafebabe usr/share/doc/fakepkg/README
diff --git a/t/fakechroot/var/lib/dpkg/status b/t/fakechroot/var/lib/dpkg/status
new file mode 100644
index 0000000..4c51cf0
--- /dev/null
+++ b/t/fakechroot/var/lib/dpkg/status
@@ -0,0 +1,10 @@
+Package: fakepkg
+Status: install ok installed
+Priority: extra
+Section: metapackages
+Installed-Size: 123
+Maintainer: Axel Beckert <abe+debsums-testsuite at debian.org>
+Architecture: all
+Version: 1
+Description: dummy package for debsums' test suite
+ This is an empty dummy package just used for debsums' test suite.
diff --git a/t/fakechroot/var/lib/dpkg/updates/.emptydir b/t/fakechroot/var/lib/dpkg/updates/.emptydir
new file mode 100644
index 0000000..e69de29
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/debsums.git
More information about the Pkg-perl-cvs-commits
mailing list