Mercurial > hg
annotate tests/test-archive @ 6289:91ac1726730a
issue 1003: send all data properly
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 16 Mar 2008 22:59:04 -0700 |
parents | 0750e4ba9d3d |
children | 118720f857b9 |
rev | line source |
---|---|
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 |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
7 hg commit -Am 1 -d '1 0' |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 echo bar>bar |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
9 hg commit -Am 2 -d '2 0' |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
10 mkdir baz |
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
11 echo bletch>baz/bletch |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
12 hg commit -Am 3 -d '1000000000 0' |
1260
4603eef60237
hgweb: use ui:username rather than web:contact
mpm@selenic.com
parents:
1166
diff
changeset
|
13 echo "[web]" >> .hg/hgrc |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
14 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
|
15 echo "allow_archive = gz bz2, zip" >> .hg/hgrc |
5924
b8009718a211
better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
16 hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log |
2571
83cfd95eafb5
tests: add timeouts, make run-tests.py clean up dead daemon processes
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2500
diff
changeset
|
17 cat hg.pid >> $DAEMON_PIDS |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
18 |
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
19 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
|
20 QTIP=`hg id -q` |
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
21 cat > getarchive.py <<EOF |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5108
diff
changeset
|
22 import os, sys, urllib2 |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
23 node, archive = sys.argv[1:] |
5384
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5108
diff
changeset
|
24 f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s' |
e3a0c092b4e2
Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5108
diff
changeset
|
25 % (os.environ['HGPORT'], node, archive)) |
1166
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 sys.stdout.write(f.read()) |
bd66294b7a9b
Added test case for zip/gz/bz2 archive downloads.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
27 EOF |
2187
09d3eebdd9b2
tests: support older version of bunzip2 and, possibly, gunzip too
TK Soh <teekaysoh@yahoo.com>
parents:
2114
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 |
2114
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
33 hg archive -t tar test.tar |
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
34 tar tf test.tar |
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
35 |
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
36 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
|
37 bunzip2 -dc test.tar.bz2 | tar tf - |
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
38 |
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
39 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
|
40 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
|
41 |
4805
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
42 cat > md5comp.py <<EOF |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
43 import md5, sys |
4805
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
44 f1, f2 = sys.argv[1:3] |
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
45 h1 = md5.md5(file(f1, 'rb').read()).hexdigest() |
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
46 h2 = md5.md5(file(f2, 'rb').read()).hexdigest() |
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
47 print h1 == h2 or "md5 differ: " + repr((h1, h2)) |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
48 EOF |
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
49 |
4805
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
50 # archive name is stored in the archive, so create similar |
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
51 # archives and rename them afterwards. |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
52 hg archive -t tgz tip.tar.gz |
4805
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
53 mv tip.tar.gz tip1.tar.gz |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
54 sleep 1 |
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
55 hg archive -t tgz tip.tar.gz |
4805
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
56 mv tip.tar.gz tip2.tar.gz |
beb774707c52
test-archive: stop checking md5 absolute values
Patrick Mezard <pmezard@gmail.com>
parents:
4653
diff
changeset
|
57 python md5comp.py tip1.tar.gz tip2.tar.gz |
4653
ca023b63ba1f
archive: test md5 consistency
Brendan Cully <brendan@kublai.com>
parents:
2571
diff
changeset
|
58 |
2114
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
59 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
|
60 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
|
61 |
6183
0750e4ba9d3d
Add config option to disable putting .hg_archival.txt inside archives.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
6020
diff
changeset
|
62 hg archive --config ui.archivemeta=false -t zip -r 2 test.zip |
2114
98cc126f9f3f
update tests after changing archival code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1929
diff
changeset
|
63 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
|
64 |
0f7e4a39d9af
archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2187
diff
changeset
|
65 hg archive -t tar - | tar tf - | sed "s/$QTIP/TIP/" |
4863
6dc0094c0827
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4805
diff
changeset
|
66 |
4836
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4805
diff
changeset
|
67 hg archive -r 0 -t tar rev-%r.tar |
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4805
diff
changeset
|
68 if [ -f rev-0.tar ]; then |
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4805
diff
changeset
|
69 echo 'rev-0.tar created' |
0e2d0a78f81a
archive: make the %r escape work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4805
diff
changeset
|
70 fi |
5061
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
71 |
6019
b70a530bdb93
cleanly abort on unknown archive type (issue966)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
72 hg archive -t bogus test.bogus |
b70a530bdb93
cleanly abort on unknown archive type (issue966)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
73 |
5924
b8009718a211
better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
74 echo % server errors |
b8009718a211
better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
75 cat errors.log |
b8009718a211
better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
76 |
5061
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
77 echo '% empty repo' |
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
78 hg init ../empty |
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
79 cd ../empty |
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
80 hg archive ../test-empty |
5924
b8009718a211
better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5384
diff
changeset
|
81 |
5061
a49f2a4d5ff7
archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents:
4836
diff
changeset
|
82 exit 0 |