tests/test-archive
author Thomas Arendsen Hein <thomas@intevation.de>
Mon, 26 Jun 2006 14:56:14 +0200
changeset 2500 76ff5efe8181
parent 2476 0f7e4a39d9af
child 2571 83cfd95eafb5
permissions -rwxr-xr-x
Fixed [web] allow_archive for comma separated parameters by using ui.configlist. Changed tests/test-archive to use allow_archive instead of the deprecated allowzip, allowgz and allowbz2.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1166
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     1
#!/bin/sh
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     2
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     3
mkdir test
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     4
cd test
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     5
hg init
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     6
echo foo>foo
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     7
hg addremove
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     8
hg commit -m 1
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     9
echo bar>bar
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    10
hg addremove
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    11
hg commit -m 2
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    12
mkdir baz
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    13
echo bletch>baz/bletch
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    14
hg addremove
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    15
hg commit -m 3
1260
4603eef60237 hgweb: use ui:username rather than web:contact
mpm@selenic.com
parents: 1166
diff changeset
    16
echo "[web]" >> .hg/hgrc
1166
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    17
echo "name = test-archive" >> .hg/hgrc
2500
76ff5efe8181 Fixed [web] allow_archive for comma separated parameters by using ui.configlist.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2476
diff changeset
    18
echo "allow_archive = gz bz2, zip" >> .hg/hgrc
1786
ffb584a182d1 Don't use mktemp in tests, we're already in a secure temp dir.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1744
diff changeset
    19
hg serve -p 20059 -d --pid-file=hg.pid
1166
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    20
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    21
TIP=`hg id -v | cut -f1 -d' '`
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    22
QTIP=`hg id -q`
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    23
cat > getarchive.py <<EOF
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    24
import sys, urllib2
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    25
node, archive = sys.argv[1:]
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    26
f = urllib2.urlopen('http://127.0.0.1:20059/?cmd=archive;node=%s;type=%s'
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    27
                    % (node, archive))
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    28
sys.stdout.write(f.read())
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    29
EOF
2187
09d3eebdd9b2 tests: support older version of bunzip2 and, possibly, gunzip too
TK Soh <teekaysoh@yahoo.com>
parents: 2114
diff changeset
    30
http_proxy= python getarchive.py "$TIP" gz | gunzip | tar tf - | sed "s/$QTIP/TIP/"
09d3eebdd9b2 tests: support older version of bunzip2 and, possibly, gunzip too
TK Soh <teekaysoh@yahoo.com>
parents: 2114
diff changeset
    31
http_proxy= python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - | sed "s/$QTIP/TIP/"
1166
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    32
http_proxy= python getarchive.py "$TIP" zip > archive.zip
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    33
unzip -t archive.zip | sed "s/$QTIP/TIP/"
bd66294b7a9b Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    34
1786
ffb584a182d1 Don't use mktemp in tests, we're already in a secure temp dir.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1744
diff changeset
    35
kill `cat hg.pid`
1923
7d83a351a936 fix testsuite for freebsd and one timingissue
Peter van Dijk <peter@dataloss.nl>
parents: 1260
diff changeset
    36
sleep 1 # wait for server to scream and die
2114
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    37
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    38
hg archive -t tar test.tar
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    39
tar tf test.tar
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    40
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    41
hg archive -t tbz2 -X baz test.tar.bz2
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    42
bunzip2 -dc test.tar.bz2 | tar tf -
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    43
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    44
hg archive -t tgz -p %b-%h test-%h.tar.gz
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    45
gzip -dc test-$QTIP.tar.gz | tar tf - | sed "s/$QTIP/TIP/"
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    46
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    47
hg archive -t zip -p /illegal test.zip
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    48
hg archive -t zip -p very/../bad test.zip
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    49
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    50
hg archive -t zip -r 2 test.zip
98cc126f9f3f update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1929
diff changeset
    51
unzip -t test.zip
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2187
diff changeset
    52
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2187
diff changeset
    53
hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/"