diff --git a/tests/md5sum.py b/tests/md5sum.py new file mode 100755 --- /dev/null +++ b/tests/md5sum.py @@ -0,0 +1,32 @@ +#! /usr/bin/env python +# +# Based on python's Tools/scripts/md5sum.py +# +# This software may be used and distributed according to the terms +# of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is +# GPL-compatible. + +import sys +import os +import md5 + +for filename in sys.argv[1:]: + try: + fp = open(filename, 'rb') + except IOError, msg: + sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) + sys.exit(1) + + m = md5.new() + try: + while 1: + data = fp.read(8192) + if not data: + break + m.update(data) + except IOError, msg: + sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) + sys.exit(1) + sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) + +sys.exit(0) diff --git a/tests/run-tests b/tests/run-tests --- a/tests/run-tests +++ b/tests/run-tests @@ -19,6 +19,9 @@ HGEDITOR=true; export HGEDITOR HGMERGE=true; export HGMERGE HGUSER="test"; export HGUSER +ECHO_N="echo -n" +[ -x /usr/ucb/echo ] && ECHO_N="/usr/ucb/echo -n" + umask 022 tests=0 @@ -40,6 +43,7 @@ HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$R } TESTDIR="$PWD" +export TESTDIR INST="$HGTMP/install" PYTHONDIR="$INST/lib/python" cd .. @@ -109,7 +113,7 @@ run_one() { # list of prerequisite programs # stuff from coreutils (cat, rm, etc) are not tested -prereqs="python merge diff grep unzip md5sum gunzip sed" +prereqs="python merge diff grep unzip gunzip sed" missing='' for pre in $prereqs ; do if type $pre > /dev/null 2>&1 ; then @@ -134,7 +138,7 @@ if [ -z "$TESTS" ] ; then fi for f in $TESTS ; do - echo -n "." + $ECHO_N "." run_one $f || failed=`expr $failed + 1` tests=`expr $tests + 1` done diff --git a/tests/test-archive b/tests/test-archive --- a/tests/test-archive +++ b/tests/test-archive @@ -29,9 +29,10 @@ f = urllib2.urlopen('http://127.0.0.1:20 % (node, archive)) sys.stdout.write(f.read()) EOF -http_proxy= python getarchive.py "$TIP" gz | tar tzf - | sed "s/$QTIP/TIP/" -http_proxy= python getarchive.py "$TIP" bz2 | tar tjf - | sed "s/$QTIP/TIP/" +http_proxy= python getarchive.py "$TIP" gz | gunzip -dc - | tar tf - | sed "s/$QTIP/TIP/" +http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 -dc - | tar tf - | sed "s/$QTIP/TIP/" http_proxy= python getarchive.py "$TIP" zip > archive.zip unzip -t archive.zip | sed "s/$QTIP/TIP/" kill `cat hg.pid` +sleep 1 # wait for server to scream and die diff --git a/tests/test-bad-pull b/tests/test-bad-pull --- a/tests/test-bad-pull +++ b/tests/test-bad-pull @@ -19,7 +19,7 @@ EOF python dumb.py 2>/dev/null & -hg clone http://localhost:20059/foo copy2 +http_proxy= hg clone http://localhost:20059/foo copy2 echo $? kill $! diff --git a/tests/test-clone b/tests/test-clone --- a/tests/test-clone +++ b/tests/test-clone @@ -16,7 +16,7 @@ hg verify # No update hg clone -U . ../c cd ../c -cat a +cat a 2>/dev/null || echo "a not present" hg verify # Default destination diff --git a/tests/test-clone.out b/tests/test-clone.out --- a/tests/test-clone.out +++ b/tests/test-clone.out @@ -4,7 +4,7 @@ checking manifests crosschecking files in changesets and manifests checking files 1 files, 1 changesets, 1 total revisions -cat: a: No such file or directory +a not present checking changesets checking manifests crosschecking files in changesets and manifests diff --git a/tests/test-conflict b/tests/test-conflict --- a/tests/test-conflict +++ b/tests/test-conflict @@ -12,5 +12,5 @@ hg commit -m branch2 -d "0 0" HGMERGE=merge; export HGMERGE hg up -m 1 hg id -grep -Ev ">>>|<<<" a +egrep -v ">>>|<<<" a hg status diff --git a/tests/test-copy b/tests/test-copy --- a/tests/test-copy +++ b/tests/test-copy @@ -20,11 +20,11 @@ echo "this should show a revision linked hg debugindex .hg/data/b.i echo "this should show the rename information in the metadata" -hg debugdata .hg/data/b.d 0 | head -n 3 | tail -n 2 +hg debugdata .hg/data/b.d 0 | head -3 | tail -2 -md5sum .hg/data/b.d +$TESTDIR/md5sum.py .hg/data/b.d hg cat b > bsum -md5sum bsum +$TESTDIR/md5sum.py bsum hg cat a > asum -md5sum asum +$TESTDIR/md5sum.py asum hg verify diff --git a/tests/test-empty-dir b/tests/test-empty-dir --- a/tests/test-empty-dir +++ b/tests/test-empty-dir @@ -10,7 +10,7 @@ hg add sub/b hg commit -m "second" -d "0 0" sub/b cat sub/b hg co 0 -cat sub/b -ls sub +cat sub/b 2>/dev/null || echo "sub/b not present" +ls sub 2>/dev/null || echo "sub not present" true diff --git a/tests/test-empty-dir.out b/tests/test-empty-dir.out --- a/tests/test-empty-dir.out +++ b/tests/test-empty-dir.out @@ -1,3 +1,3 @@ 321 -cat: sub/b: No such file or directory -ls: sub: No such file or directory +sub/b not present +sub not present diff --git a/tests/test-flags b/tests/test-flags --- a/tests/test-flags +++ b/tests/test-flags @@ -30,5 +30,5 @@ hg history hg -v co -m ls -l ../test[12]/a > foo -cut -b 0-10 < foo +cut -b 1-10 < foo diff --git a/tests/test-pull b/tests/test-pull --- a/tests/test-pull +++ b/tests/test-pull @@ -10,7 +10,7 @@ hg verify hg serve -p 20059 -d --pid-file=hg.pid cd .. -hg clone http://localhost:20059/ copy +http_proxy= hg clone http://localhost:20059/ copy cd copy hg verify hg co diff --git a/tests/test-static-http b/tests/test-static-http --- a/tests/test-static-http +++ b/tests/test-static-http @@ -1,7 +1,8 @@ #!/bin/sh -http_proxy= hg clone old-http://localhost:20059/ copy +http_proxy= hg clone old-http://localhost:20059/ copy > clonefail.out 2>&1 echo $? +sed 's/[0-9]//g' < clonefail.out ls copy # This server doesn't do range requests so it's basically only good for diff --git a/tests/test-static-http.out b/tests/test-static-http.out --- a/tests/test-static-http.out +++ b/tests/test-static-http.out @@ -1,5 +1,5 @@ +255 abort: Connection refused -255 ls: copy: No such file or directory changeset: 0:61c9426e69fe tag: tip