* Benjamin Drung <bdr...@debian.org> [2013-11-02 13:08]:

On Sa, 2013-11-02 at 12:03 +0100, Rafael Laboissiere wrote:
* Benjamin Drung <bdr...@debian.org> [2013-11-02 00:05]:

I have just one recommendation/wish: It would be nice if test cases could be added for the new feature. The test cases should work offline.

Would something along the lines of the very simple-minded shell script attached below be appropriate? Of course, it will need adaptation for the shunit2 framework used in devscripts.

Yes, that's exactly what I hoped for. We already have test/test_uscan, which contains one online test. This could be converted to an offline test with your test framework.

What this script does is (1) create a minimal Debian package directory, containing minimal files debian/{changelog,watch,copyright}, (2) create a minimal repository, containing a tarball (built on the fly), and (3) start an HTTP server that works offline, using the SimpleHTTPServer module of Python.

Maybe this short description could be added to the test case as comment (for documentation).

Ok, I did it and also changed test/Makefile accordingly. The patch is attached below. Note that I also added an entry in debian/copyright, but that may be wrong. There is no need to build-depend on libpython-stdlib (for the SimpleHTTPServer module), because python3-all pulls it in. This patch works here inside my pbuilder.

Cheers,

Rafael Laboissière

>From 23bd86aad69f15f83effb133237fcdd9c48daae5 Mon Sep 17 00:00:00 2001
From: Rafael Laboissiere <raf...@laboissiere.net>
Date: Sat, 2 Nov 2013 18:15:54 +0100
Subject: [PATCH] Add test for the file exclusion feature of uscan

---
 debian/copyright               |  2 ++
 test/Makefile                  |  1 +
 test/test_uscan_file_exclusion | 73 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+)
 create mode 100755 test/test_uscan_file_exclusion

diff --git a/debian/copyright b/debian/copyright
index 515cb94..1e28919 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -62,9 +62,11 @@ License: GPL-3
 
 Files: doc/what-patch.1
        scripts/what-patch.sh
+       test/test_uscan_file_exclusio
 Copyright: 2009,      Jonathan Patrick Davies <j...@ubuntu.com>
            2006-2008, Kees Cook <k...@ubuntu.com>
            2007-2008, Siegfried-Angel Gevatter Pujals <rai...@ubuntu.com>
+           2013,      Rafael Laboissiere <raf...@laboissiere.net>
 License: GPL-3+
  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
diff --git a/test/Makefile b/test/Makefile
index 7b10a5c..75ca9ff 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -5,6 +5,7 @@ test:
 	./test_debchange
 	./test_debdiff
 	./test_licensecheck
+	./test_uscan_file_exclusion
 
 online-test:
 	./test_uscan
diff --git a/test/test_uscan_file_exclusion b/test/test_uscan_file_exclusion
new file mode 100755
index 0000000..f3a3db2
--- /dev/null
+++ b/test/test_uscan_file_exclusion
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# Copyright (C) 2013, Rafael Laboissiere <raf...@laboissiere.net>
+#
+# 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.
+#
+# On Debian systems, the complete text of the GNU General Public License
+# version 3 can be found in the /usr/share/common-licenses/GPL-3 file.
+
+# This script tests the Files-Excluded feature of uscan, which allows the
+# selective exclusion of files from thje upstream tarball before repacking
+# it.
+#
+# This script does the following: (1) create a minimal Debian package
+# directory, containing minimal files debian/{changelog,watch,copyright},
+# (2) create a minimal repository, containing a tarball (built on the fly),
+# (3) start an HTTP server that works offline, using the SimpleHTTPServer
+# module of Python, and (4) run uscan inside that minimal universe.
+
+export PERLLIB="$PWD/.."
+COMMAND="$PWD/../scripts/uscan.pl"
+
+TMPDIR=$(mktemp -d)
+
+cleanup(){
+    rm -rf $TMPDIR
+    kill -9 $pid
+}
+
+trap cleanup 1 2 3 13 15
+
+mkdir -p $TMPDIR/foo/debian
+
+cat <<END > $TMPDIR/foo/debian/watch
+version=3
+http://localhost:8000/foo-(\d).tar.gz
+END
+
+cat <<END > $TMPDIR/foo/debian/changelog
+foo (0-1) unstable; urgency=low
+
+  * Initial release
+
+ -- Joe Developer <j...@debian.org>  Mon, 02 Nov 2013 22:21:31 -0100
+END
+
+cat <<END > $TMPDIR/foo/debian/copyright
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Files-Excluded: exclude-this
+END
+
+mkdir -p $TMPDIR/repo/foo
+touch $TMPDIR/repo/foo/include-this
+touch $TMPDIR/repo/foo/exclude-this
+cd $TMPDIR/repo
+tar cfvz foo-1.tar.gz foo
+
+python -m SimpleHTTPServer 8000 &
+pid=$!
+
+( cd $TMPDIR/foo ; $COMMAND )
+
+( cd $TMPDIR ; tar tfvz foo_1+dfsg.orig.tar.gz )
+
+cleanup
-- 
1.8.4.rc3

Reply via email to