tests/test-hgwebdir
author David Soria Parra <dsp@php.net>
Sun, 07 Dec 2008 08:47:02 +0100
changeset 7485 ecfb683675ed
parent 7450 79d1bb737c16
child 7494 85dc88630beb
permissions -rwxr-xr-x
Merge bookmarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     1
#!/bin/sh
5580
f429e0e067a8 Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5578
diff changeset
     2
# Tests some basic hgwebdir functionality. Tests setting up paths and
f429e0e067a8 Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5578
diff changeset
     3
# collection, different forms of 404s and the subdirectory support.
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     4
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     5
mkdir webdir
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     6
cd webdir
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     7
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     8
hg init a
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     9
echo a > a/a
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    10
hg --cwd a ci -Ama -d'1 0'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    11
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    12
hg init b
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    13
echo b > b/b
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    14
hg --cwd b ci -Amb -d'2 0'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    15
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    16
hg init c
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    17
echo c > c/c
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    18
hg --cwd c ci -Amc -d'3 0'
7202
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    19
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    20
cd b
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    21
hg init d
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    22
echo d > d/d
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    23
hg --cwd d ci -Amd
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    24
cd ..
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    25
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    26
root=`pwd`
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    27
cd ..
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    28
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    29
cat > paths.conf <<EOF
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    30
[paths]
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    31
a=$root/a
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    32
b=$root/b
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    33
EOF
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    34
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    35
hg serve -p $HGPORT -d --pid-file=hg.pid --webdir-conf paths.conf \
5601
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    36
    -A access-paths.log -E error-paths-1.log
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    37
cat hg.pid >> $DAEMON_PIDS
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    38
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    39
echo % should give a 404 - file does not exist
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    40
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/file/tip/bork?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    41
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    42
echo % should succeed
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    43
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    44
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/file/tip/a?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    45
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/b/file/tip/b?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    46
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    47
echo % should give a 404 - repo is not published
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    48
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    49
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    50
cat > paths.conf <<EOF
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    51
[paths]
5586
b90b72729a72 hgwebdir: test virtual paths leading or trailing separators are stripped
Patrick Mezard <pmezard@gmail.com>
parents: 5580
diff changeset
    52
t/a/=$root/a
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    53
b=$root/b
7450
79d1bb737c16 hgweb: extend [paths] syntax to match repositories recursively (issue852)
Patrick Mezard <pmezard@gmail.com>
parents: 7202
diff changeset
    54
coll=$root/*
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    55
EOF
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    56
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    57
hg serve -p $HGPORT1 -d --pid-file=hg.pid --webdir-conf paths.conf \
5601
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    58
    -A access-paths.log -E error-paths-2.log
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    59
cat hg.pid >> $DAEMON_PIDS
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    60
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    61
echo % should succeed, slashy names
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    62
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    63
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    64
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    65
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a?style=atom' \
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    66
	| sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//"
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    67
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/?style=atom' \
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    68
	| sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//"
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    69
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/t/a/file/tip/a?style=raw'
7450
79d1bb737c16 hgweb: extend [paths] syntax to match repositories recursively (issue852)
Patrick Mezard <pmezard@gmail.com>
parents: 7202
diff changeset
    70
# Test [paths] '*' extension
79d1bb737c16 hgweb: extend [paths] syntax to match repositories recursively (issue852)
Patrick Mezard <pmezard@gmail.com>
parents: 7202
diff changeset
    71
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/coll/?style=raw'
79d1bb737c16 hgweb: extend [paths] syntax to match repositories recursively (issue852)
Patrick Mezard <pmezard@gmail.com>
parents: 7202
diff changeset
    72
"$TESTDIR/get-with-headers.py" localhost:$HGPORT1 '/coll/a/file/tip/a?style=raw'
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    73
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    74
cat > collections.conf <<EOF
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    75
[collections]
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    76
$root=$root
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    77
EOF
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    78
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    79
hg serve -p $HGPORT2 -d --pid-file=hg.pid --webdir-conf collections.conf \
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    80
    -A access-collections.log -E error-collections.log
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    81
cat hg.pid >> $DAEMON_PIDS
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    82
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    83
echo % should succeed
5578
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    84
"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    85
"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/file/tip/a?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    86
"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/file/tip/b?style=raw'
733b50883f73 Add tests for hgwebdir repository names with slashes in them.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5561
diff changeset
    87
"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/c/file/tip/c?style=raw'
7202
268c582bd42a tests: add more testing for webdir nesting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5601
diff changeset
    88
"$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/d/rev/tip/?style=raw'
5601
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    89
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    90
echo % paths errors 1
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    91
cat error-paths-1.log
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    92
echo % paths errors 2
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    93
cat error-paths-2.log
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    94
echo % collections errors
8279cb841467 hgwebdir: split out makeindex function, facilitate test failure diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5586
diff changeset
    95
cat error-collections.log