# HG changeset patch # User Matt Mackall # Date 1285526492 18000 # Node ID 7f3af5da4e6c418698aaf63d73f6e30808f105a2 # Parent d911aa2b8570cd9791b8e72da49deaf525292b12 tests: unify test-hgweb diff -r d911aa2b8570 -r 7f3af5da4e6c tests/test-hgweb --- a/tests/test-hgweb Sun Sep 26 13:41:32 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#!/bin/sh -# Some tests for hgweb. Tests static files, plain files and different 404's. - -hg init test -cd test -mkdir da -echo foo > da/foo -echo foo > foo -hg ci -Ambase - -hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log -cat hg.pid >> $DAEMON_PIDS - -echo % manifest -("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=raw') -("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/da?style=raw') - -echo % plain file -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?style=raw' - -echo % should give a 404 - static file that does not exist -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/bogus' - -echo % should give a 404 - bad revision -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/spam/foo?style=raw' - -echo % should give a 400 - bad command -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?cmd=spam&style=raw' | sed 's/400.*/400/' - -echo % should give a 404 - file does not exist -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw' -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork' -"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw' - -echo % try bad style -("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=foobar') - -echo % stop and restart -"$TESTDIR/killdaemons.py" -hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -cat hg.pid >> $DAEMON_PIDS -# Test the access/error files are opened in append mode -python -c "print len(file('access.log').readlines()), 'log lines written'" - -echo % static file -"$TESTDIR/get-with-headers.py" --twice localhost:$HGPORT '/static/style-gitweb.css' - -echo % errors -cat errors.log diff -r d911aa2b8570 -r 7f3af5da4e6c tests/test-hgweb.out --- a/tests/test-hgweb.out Sun Sep 26 13:41:32 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,370 +0,0 @@ -adding da/foo -adding foo -% manifest -200 Script output follows - - -drwxr-xr-x da --rw-r--r-- 4 foo - - -200 Script output follows - - --rw-r--r-- 4 foo - - -% plain file -200 Script output follows - -foo -% should give a 404 - static file that does not exist -404 Not Found - - - - - - - - -test: error - - - -
- - -
- -

test

-

error

- - - -
-

-An error occurred while processing your request: -

-

-Not Found -

-
-
-
- - - - - - -% should give a 404 - bad revision -404 Not Found - - -error: revision not found: spam -% should give a 400 - bad command -400 - - -error: no such method: spam -% should give a 404 - file does not exist -404 Not Found - - -error: bork@2ef0ac749a14: not found in manifest -404 Not Found - - - - - - - - -test: error - - - -
- - -
- -

test

-

error

- - - -
-

-An error occurred while processing your request: -

-

-bork@2ef0ac749a14: not found in manifest -

-
-
-
- - - - - - -404 Not Found - - -error: bork@2ef0ac749a14: not found in manifest -% try bad style -200 Script output follows - - - - - - - - -test: 2ef0ac749a14 / - - - -
- - -
-

test

-

directory / @ 0:2ef0ac749a14 tip

- - - - - - - - - - - - - - - - - - - - - - - - - - -
namesizepermissions
[up]drwxr-xr-x
- -dir. da/ - - - - -drwxr-xr-x
- -file foo - -4-rw-r--r--
-
-
- - - - - -% stop and restart -10 log lines written -% static file -200 Script output follows - -body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; } -a { color:#0000cc; } -a:hover, a:visited, a:active { color:#880000; } -div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } -div.page_header a:visited { color:#0000cc; } -div.page_header a:hover { color:#880000; } -div.page_nav { padding:8px; } -div.page_nav a:visited { color:#0000cc; } -div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} -div.page_footer { padding:4px 8px; background-color: #d9d8d1; } -div.page_footer_text { float:left; color:#555555; font-style:italic; } -div.page_body { padding:8px; } -div.title, a.title { - display:block; padding:6px 8px; - font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; -} -a.title:hover { background-color: #d9d8d1; } -div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; } -div.log_body { padding:8px 8px 8px 150px; } -.age { white-space:nowrap; } -span.age { position:relative; float:left; width:142px; font-style:italic; } -div.log_link { - padding:0px 8px; - font-size:10px; font-family:sans-serif; font-style:normal; - position:relative; float:left; width:136px; -} -div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } -a.list { text-decoration:none; color:#000000; } -a.list:hover { text-decoration:underline; color:#880000; } -table { padding:8px 4px; } -th { padding:2px 5px; font-size:12px; text-align:left; } -tr.light:hover, .parity0:hover { background-color:#edece6; } -tr.dark, .parity1 { background-color:#f6f6f0; } -tr.dark:hover, .parity1:hover { background-color:#edece6; } -td { padding:2px 5px; font-size:12px; vertical-align:top; } -td.closed { background-color: #99f; } -td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } -td.indexlinks { white-space: nowrap; } -td.indexlinks a { - padding: 2px 5px; line-height: 10px; - border: 1px solid; - color: #ffffff; background-color: #7777bb; - border-color: #aaaadd #333366 #333366 #aaaadd; - font-weight: bold; text-align: center; text-decoration: none; - font-size: 10px; -} -td.indexlinks a:hover { background-color: #6666aa; } -div.pre { font-family:monospace; font-size:12px; white-space:pre; } -div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } -div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } -div.search { margin:4px 8px; position:absolute; top:56px; right:12px } -.linenr { color:#999999; text-decoration:none } -div.rss_logo { float: right; white-space: nowrap; } -div.rss_logo a { - padding:3px 6px; line-height:10px; - border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; - color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; font-size:10px; - text-align:center; text-decoration:none; -} -div.rss_logo a:hover { background-color:#ee5500; } -pre { margin: 0; } -span.logtags span { - padding: 0px 4px; - font-size: 10px; - font-weight: normal; - border: 1px solid; - background-color: #ffaaff; - border-color: #ffccff #ff00ee #ff00ee #ffccff; -} -span.logtags span.tagtag { - background-color: #ffffaa; - border-color: #ffffcc #ffee00 #ffee00 #ffffcc; -} -span.logtags span.branchtag { - background-color: #aaffaa; - border-color: #ccffcc #00cc33 #00cc33 #ccffcc; -} -span.logtags span.inbranchtag { - background-color: #d5dde6; - border-color: #e3ecf4 #9398f4 #9398f4 #e3ecf4; -} - -/* Graph */ -div#wrapper { - position: relative; - margin: 0; - padding: 0; - margin-top: 3px; -} - -canvas { - position: absolute; - z-index: 5; - top: -0.9em; - margin: 0; -} - -ul#nodebgs { - list-style: none inside none; - padding: 0; - margin: 0; - top: -0.7em; -} - -ul#graphnodes li, ul#nodebgs li { - height: 39px; -} - -ul#graphnodes { - position: absolute; - z-index: 10; - top: -0.8em; - list-style: none inside none; - padding: 0; -} - -ul#graphnodes li .info { - display: block; - font-size: 100%; - position: relative; - top: -3px; - font-style: italic; -} -304 Not Modified - -% errors diff -r d911aa2b8570 -r 7f3af5da4e6c tests/test-hgweb.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-hgweb.t Sun Sep 26 13:41:32 2010 -0500 @@ -0,0 +1,425 @@ +Some tests for hgweb. Tests static files, plain files and different 404's. + + $ hg init test + $ cd test + $ mkdir da + $ echo foo > da/foo + $ echo foo > foo + $ hg ci -Ambase + adding da/foo + adding foo + $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + +manifest + + $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=raw') + 200 Script output follows + + + drwxr-xr-x da + -rw-r--r-- 4 foo + + + $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/da?style=raw') + 200 Script output follows + + + -rw-r--r-- 4 foo + + + +plain file + + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?style=raw' + 200 Script output follows + + foo + +should give a 404 - static file that does not exist + + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/bogus' + 404 Not Found + + + + + + + + + test: error + + + +
+ + +
+ +

test

+

error

+ + + +
+

+ An error occurred while processing your request: +

+

+ Not Found +

+
+
+
+ + + + + + + [1] + +should give a 404 - bad revision + + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/spam/foo?style=raw' + 404 Not Found + + + error: revision not found: spam + [1] + +should give a 400 - bad command + + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/foo?cmd=spam&style=raw' + 400* (glob) + + + error: no such method: spam + [1] + +should give a 404 - file does not exist + + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork?style=raw' + 404 Not Found + + + error: bork@2ef0ac749a14: not found in manifest + [1] + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/bork' + 404 Not Found + + + + + + + + + test: error + + + +
+ + +
+ +

test

+

error

+ + + +
+

+ An error occurred while processing your request: +

+

+ bork@2ef0ac749a14: not found in manifest +

+
+
+
+ + + + + + + [1] + $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/tip/bork?style=raw' + 404 Not Found + + + error: bork@2ef0ac749a14: not found in manifest + [1] + +try bad style + + $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/?style=foobar') + 200 Script output follows + + + + + + + + + test: 2ef0ac749a14 / + + + +
+ + +
+

test

+

directory / @ 0:2ef0ac749a14 tip

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
namesizepermissions
[up]drwxr-xr-x
+ + dir. da/ + + + + + drwxr-xr-x
+ + file foo + + 4-rw-r--r--
+
+
+ + + + + + +stop and restart + + $ "$TESTDIR/killdaemons.py" + $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log + $ cat hg.pid >> $DAEMON_PIDS + +Test the access/error files are opened in append mode + + $ python -c "print len(file('access.log').readlines()), 'log lines written'" + 10 log lines written + +static file + + $ "$TESTDIR/get-with-headers.py" --twice localhost:$HGPORT '/static/style-gitweb.css' + 200 Script output follows + + body { font-family: sans-serif; font-size: 12px; margin:0px; border:solid #d9d8d1; border-width:1px; margin:10px; } + a { color:#0000cc; } + a:hover, a:visited, a:active { color:#880000; } + div.page_header { height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } + div.page_header a:visited { color:#0000cc; } + div.page_header a:hover { color:#880000; } + div.page_nav { padding:8px; } + div.page_nav a:visited { color:#0000cc; } + div.page_path { padding:8px; border:solid #d9d8d1; border-width:0px 0px 1px} + div.page_footer { padding:4px 8px; background-color: #d9d8d1; } + div.page_footer_text { float:left; color:#555555; font-style:italic; } + div.page_body { padding:8px; } + div.title, a.title { + display:block; padding:6px 8px; + font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; + } + a.title:hover { background-color: #d9d8d1; } + div.title_text { padding:6px 0px; border: solid #d9d8d1; border-width:0px 0px 1px; } + div.log_body { padding:8px 8px 8px 150px; } + .age { white-space:nowrap; } + span.age { position:relative; float:left; width:142px; font-style:italic; } + div.log_link { + padding:0px 8px; + font-size:10px; font-family:sans-serif; font-style:normal; + position:relative; float:left; width:136px; + } + div.list_head { padding:6px 8px 4px; border:solid #d9d8d1; border-width:1px 0px 0px; font-style:italic; } + a.list { text-decoration:none; color:#000000; } + a.list:hover { text-decoration:underline; color:#880000; } + table { padding:8px 4px; } + th { padding:2px 5px; font-size:12px; text-align:left; } + tr.light:hover, .parity0:hover { background-color:#edece6; } + tr.dark, .parity1 { background-color:#f6f6f0; } + tr.dark:hover, .parity1:hover { background-color:#edece6; } + td { padding:2px 5px; font-size:12px; vertical-align:top; } + td.closed { background-color: #99f; } + td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } + td.indexlinks { white-space: nowrap; } + td.indexlinks a { + padding: 2px 5px; line-height: 10px; + border: 1px solid; + color: #ffffff; background-color: #7777bb; + border-color: #aaaadd #333366 #333366 #aaaadd; + font-weight: bold; text-align: center; text-decoration: none; + font-size: 10px; + } + td.indexlinks a:hover { background-color: #6666aa; } + div.pre { font-family:monospace; font-size:12px; white-space:pre; } + div.diff_info { font-family:monospace; color:#000099; background-color:#edece6; font-style:italic; } + div.index_include { border:solid #d9d8d1; border-width:0px 0px 1px; padding:12px 8px; } + div.search { margin:4px 8px; position:absolute; top:56px; right:12px } + .linenr { color:#999999; text-decoration:none } + div.rss_logo { float: right; white-space: nowrap; } + div.rss_logo a { + padding:3px 6px; line-height:10px; + border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; font-size:10px; + text-align:center; text-decoration:none; + } + div.rss_logo a:hover { background-color:#ee5500; } + pre { margin: 0; } + span.logtags span { + padding: 0px 4px; + font-size: 10px; + font-weight: normal; + border: 1px solid; + background-color: #ffaaff; + border-color: #ffccff #ff00ee #ff00ee #ffccff; + } + span.logtags span.tagtag { + background-color: #ffffaa; + border-color: #ffffcc #ffee00 #ffee00 #ffffcc; + } + span.logtags span.branchtag { + background-color: #aaffaa; + border-color: #ccffcc #00cc33 #00cc33 #ccffcc; + } + span.logtags span.inbranchtag { + background-color: #d5dde6; + border-color: #e3ecf4 #9398f4 #9398f4 #e3ecf4; + } + + /* Graph */ + div#wrapper { + position: relative; + margin: 0; + padding: 0; + margin-top: 3px; + } + + canvas { + position: absolute; + z-index: 5; + top: -0.9em; + margin: 0; + } + + ul#nodebgs { + list-style: none inside none; + padding: 0; + margin: 0; + top: -0.7em; + } + + ul#graphnodes li, ul#nodebgs li { + height: 39px; + } + + ul#graphnodes { + position: absolute; + z-index: 10; + top: -0.8em; + list-style: none inside none; + padding: 0; + } + + ul#graphnodes li .info { + display: block; + font-size: 100%; + position: relative; + top: -3px; + font-style: italic; + } + 304 Not Modified + + +errors + + $ cat errors.log