tests/test-hgweb
author David Champion <dgc@uchicago.edu>
Mon, 10 May 2010 11:04:56 -0500
changeset 11148 a912f26777d3
parent 9842 d3dbdca92458
child 12182 1121af239761
permissions -rwxr-xr-x
merge: introduce tool.check parameter tool.check is a list of check options, and can be used in place of tool.checkchanged and tool.checkconflicts: Equivalences: tool.checkchanged = yes tool.checkconflicts = no tool.check = changed tool.checkchanged = no tool.checkconflicts = yes tool.check = conflicts tool.checkchanged = yes tool.checkconflicts = yes tool.check = changed, conflicts Add _toollist() wrapper for ui.configlist() to implement this consistently. checkchanged and checkconflicts are still supported, but check is preferred for implementing new check options.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3942
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     1
#!/bin/sh
5580
f429e0e067a8 Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5564
diff changeset
     2
# Some tests for hgweb. Tests static files, plain files and different 404's.
3942
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     3
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     4
hg init test
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     5
cd test
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     6
mkdir da
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     7
echo foo > da/foo
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
     8
echo foo > foo
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7428
diff changeset
     9
hg ci -Ambase
9842
d3dbdca92458 hgweb: don't choke when an inexistent style is requested (issue1901)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8167
diff changeset
    10
7341
6cb522c5d56a tests: fix test-hgweb to not leak directory name
Matt Mackall <mpm@selenic.com>
parents: 6368
diff changeset
    11
hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    12
cat hg.pid >> $DAEMON_PIDS
9842
d3dbdca92458 hgweb: don't choke when an inexistent style is requested (issue1901)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8167
diff changeset
    13
3942
8eccfce0ab5e hgweb: simple tests
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
    14
echo % manifest
5384
e3a0c092b4e2 Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3942
diff changeset
    15
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=raw')
e3a0c092b4e2 Allow tests to run in parallel.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3942
diff changeset
    16
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/da?style=raw')
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    17
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    18
echo % plain file
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    19
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    20
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    21
echo % should give a 404 - static file that does not exist
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    22
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/bogus'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    23
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    24
echo % should give a 404 - bad revision
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    25
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/spam/foo?style=raw'
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    26
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    27
echo % should give a 400 - bad command
5564
b4af2dd9868a hgweb: account for Python 2.4 in one test
Bryan O'Sullivan <bos@serpentine.com>
parents: 5561
diff changeset
    28
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?cmd=spam&style=raw' | sed 's/400.*/400/'
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    29
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    30
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: 5384
diff changeset
    31
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw'
6368
2c370f08c486 hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5924
diff changeset
    32
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork'
2c370f08c486 hgweb: better error messages
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5924
diff changeset
    33
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw'
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    34
9842
d3dbdca92458 hgweb: don't choke when an inexistent style is requested (issue1901)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8167
diff changeset
    35
echo % try bad style
d3dbdca92458 hgweb: don't choke when an inexistent style is requested (issue1901)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8167
diff changeset
    36
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=foobar')
d3dbdca92458 hgweb: don't choke when an inexistent style is requested (issue1901)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8167
diff changeset
    37
5690
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    38
echo % stop and restart
7428
fdcde929ce4f tests: use killdaemons in hgweb tests
Mads Kiilerich <mads@kiilerich.com>
parents: 7341
diff changeset
    39
"$TESTDIR/killdaemons.py"
5690
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    40
hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    41
cat hg.pid >> $DAEMON_PIDS
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    42
# Test the access/error files are opened in append mode
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    43
python -c "print len(file('access.log').readlines()), 'log lines written'"
1b365c5723bc server: append to logfiles
Mirko Friedenhagen <mirko-lists@friedenhagen.de>
parents: 5580
diff changeset
    44
5561
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    45
echo % static file
22713dce19f6 hgweb: return meaningful HTTP status codes instead of nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents: 5384
diff changeset
    46
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/style-gitweb.css'
5924
b8009718a211 better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5690
diff changeset
    47
b8009718a211 better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5690
diff changeset
    48
echo % errors
b8009718a211 better error reporting for hg serve errors in tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5690
diff changeset
    49
cat errors.log