This is an automated email from the git hooks/post-receive script. jamessan pushed a commit to branch master in repository devscripts.
commit dbc994ac1e83bc09b97daeb297c8dc2b2709ebc0 Author: James McCoy <[email protected]> Date: Thu Mar 12 23:27:04 2015 -0400 uscan: Run test HTTP server on OS assigned port Hard-coding the HTTP server port to 8000 causes test failures when the port is already in use (as has happened in some CI environments). Add our own test server which logs the port it's using before going into service. Adjust the tests to read the port back before creating the watch files. Signed-off-by: James McCoy <[email protected]> --- debian/changelog | 7 +++++-- test/test_uscan | 48 ++++++++++++++++++++++++++++-------------------- test/uscan/server.py | 16 ++++++++++++++++ 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/debian/changelog b/debian/changelog index e761175..ef80c01 100644 --- a/debian/changelog +++ b/debian/changelog @@ -34,8 +34,11 @@ devscripts (2.15.1+exp1) UNRELEASED; urgency=medium * who-permits-upload: Update URL to use https. * Replace use of Parse::DebControl with Dpkg::Control to work around #780138 and remove a dependency. - * uscan: Always remove the Referer header for Sourceforge, not just when - going via the redirector. (Closes: #778860) + * uscan: + + Always remove the Referer header for Sourceforge, not just when going + via the redirector. (Closes: #778860) + + Let the OS assign a port to the test's HTTP server so tests don't fail + when something is already using port 8000. [ Johannes Schauer ] * chdist: Also set Apt::Architectures to prevent foreign architectures from diff --git a/test/test_uscan b/test/test_uscan index ff04cef..f45c8c7 100755 --- a/test/test_uscan +++ b/test/test_uscan @@ -15,6 +15,7 @@ # 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. +test_dir=$(readlink -f "${0%/*}") if test "$1" = --installed; then COMMAND="uscan --no-conf --compression=xz" shift @@ -36,6 +37,18 @@ cleanup(){ rm -rf $TMPDIR } +spawnHttpServer(){ + ( + mkdir -p $TMPDIR/repo + cd $TMPDIR/repo + python "$test_dir/uscan/server.py" & + echo $! > pid + while ! [ -s port ]; do + : + done + ) +} + trap cleanup 1 2 3 13 15 containsName(){ @@ -59,10 +72,11 @@ helperTestRepack() { file_output="$3" PKG=foo - PORT=8000 TMPDIR=$(mktemp -d) mkdir -p $TMPDIR/$PKG/debian + spawnHttpServer + PORT=$(cat $TMPDIR/repo/port) cat <<END > $TMPDIR/$PKG/debian/watch version=3 @@ -81,9 +95,7 @@ END touch $TMPDIR/repo/foo/content ( cd $TMPDIR/repo ; - tar cfa $PKG-1.$from_ext * ; - python -m SimpleHTTPServer $PORT & - echo $! > pid ) + tar cfa $PKG-1.$from_ext * ) OUTPUT=$( (cd $TMPDIR/$PKG ; $COMMAND --dehs --repack --compression=$to_comp) 2>&1 ) @@ -118,8 +130,9 @@ testRepackZip_XZ() { file_output="XZ compressed data" PKG=foo - PORT=8000 TMPDIR=$(mktemp -d) + spawnHttpServer + PORT=$(cat $TMPDIR/repo/port) mkdir -p $TMPDIR/$PKG/debian @@ -140,9 +153,7 @@ END touch $TMPDIR/repo/foo/content ( cd $TMPDIR/repo ; - zip -q -r $PKG-1.zip * ; - python -m SimpleHTTPServer $PORT & - echo $! > pid ) + zip -q -r $PKG-1.zip * ) OUTPUT=$( (cd $TMPDIR/$PKG ; $COMMAND --dehs --repack --compression=$to_comp) ) @@ -226,17 +237,16 @@ helperTestContent() { testFileExclusion() { PKG=foo - PORT=8000 TMPDIR=$(mktemp -d) + spawnHttpServer + PORT=$(cat $TMPDIR/repo/port) ( cd $TMPDIR OPTS="opts=repacksuffix=+dfsg1 " helperCreateRepo cd repo - tar cfz $PKG-1.tar.gz * .hidden - python -m SimpleHTTPServer $PORT & - echo $! > pid ) + tar cfz $PKG-1.tar.gz * .hidden ) (cd $TMPDIR/$PKG ; $COMMAND) @@ -258,17 +268,16 @@ testFileExclusion() { testFileExclusionSeparateDir() { PKG=foo - PORT=8000 TMPDIR=$(mktemp -d) + spawnHttpServer + PORT=$(cat $TMPDIR/repo/port) ( cd $TMPDIR OPTS="opts=repacksuffix=+dfsg1 " helperCreateRepo cd repo - tar cfz $PKG-1.tar.gz * .hidden - python -m SimpleHTTPServer $PORT & - echo $! > pid ) + tar cfz $PKG-1.tar.gz * .hidden ) mkdir $TMPDIR/otherdir ( @@ -294,8 +303,9 @@ testFileExclusionSeparateDir() { testFileExclusionZipToTar() { PKG=foo - PORT=8000 TMPDIR=$(mktemp -d) + spawnHttpServer + PORT=$(cat $TMPDIR/repo/port) ( cd $TMPDIR @@ -306,9 +316,7 @@ opts=repacksuffix=+dfsg1 http://localhost:$PORT/$PKG-(\d).zip END cd repo - zip -q -r $PKG-1.zip * .hidden; - python -m SimpleHTTPServer $PORT & - echo $! > pid ) + zip -q -r $PKG-1.zip * .hidden ) (cd $TMPDIR/$PKG ; $COMMAND --repack) diff --git a/test/uscan/server.py b/test/uscan/server.py new file mode 100644 index 0000000..7309288 --- /dev/null +++ b/test/uscan/server.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +import BaseHTTPServer +from SimpleHTTPServer import SimpleHTTPRequestHandler + +def test(): + SimpleHTTPRequestHandler.protocol_version='HTTP/1.0' + httpd = BaseHTTPServer.HTTPServer(('', 0), SimpleHTTPRequestHandler) + + sa = httpd.socket.getsockname() + with open('port', 'w') as f: + f.write(str(sa[1])) + + httpd.serve_forever() + +if __name__ == '__main__': + test() -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git _______________________________________________ devscripts-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel
