# HG changeset patch # User Dirkjan Ochtman # Date 1206213390 -3600 # Node ID 3b841c189ab75ebb4196fd0952f9d1c71901d28e # Parent 57a47660b3198209e8664c910b25b1dac45a402c tests: add highlight extension tests diff -r 57a47660b319 -r 3b841c189ab7 tests/hghave --- a/tests/hghave Sat Mar 22 18:33:10 2008 +0100 +++ b/tests/hghave Sat Mar 22 20:16:30 2008 +0100 @@ -107,6 +107,13 @@ finally: os.rmdir(d) +def has_pygments(): + try: + import pygments + return True + except ImportError: + return False + checks = { "baz": (has_baz, "GNU Arch baz client"), "cvs": (has_cvs, "cvs client"), @@ -123,6 +130,7 @@ "symlink": (has_symlink, "symbolic links"), "tla": (has_tla, "GNU Arch tla client"), "unix-permissions": (has_unix_permissions, "unix-style permissions"), + "pygments": (has_pygments, "Pygments source highlighting library"), } def list_features(): diff -r 57a47660b319 -r 3b841c189ab7 tests/test-highlight --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-highlight Sat Mar 22 20:16:30 2008 +0100 @@ -0,0 +1,29 @@ +#!/bin/sh + +"$TESTDIR/hghave" pygments || exit 80 + +cat <> $HGRCPATH +[extensions] +hgext.highlight = +EOF + +hg init test +cd test +cp $TESTDIR/get-with-headers.py ./ +hg ci -Ama + +echo % hg serve +hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log +cat hg.pid >> $DAEMON_PIDS + +echo % hgweb filerevision +("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \ + | sed "s/[0-9]* years ago/long ago/g" + +echo % hgweb fileannotate +("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \ + | sed "s/[0-9]* years ago/long ago/g" + +echo % errors encountered +cat errors.log + diff -r 57a47660b319 -r 3b841c189ab7 tests/test-highlight.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-highlight.out Sat Mar 22 20:16:30 2008 +0100 @@ -0,0 +1,129 @@ +adding get-with-headers.py +% hg serve +% hgweb filerevision +200 Script output follows + + + + + + + + + +test:get-with-headers.py + + + + + +

get-with-headers.py

+ + + + + + + + + + + + + + + + + + + + +
changeset 0:79ee608ca36d
author:test
date:Thu Jan 01 00:00:00 1970 +0000 (long ago)
permissions:-rwxr-xr-x
description:a
+ +
+
1#!/usr/bin/env python
3__doc__ = """This does HTTP get requests given a host:port and path and returns
4a subset of the headers plus the body of the result."""
6import httplib, sys
7headers = [h.lower() for h in sys.argv[3:]]
8conn = httplib.HTTPConnection(sys.argv[1])
9conn.request("GET", sys.argv[2])
10response = conn.getresponse()
11print response.status, response.reason
12for h in headers:
13 if response.getheader(h, None) is not None:
14 print "%s: %s" % (h, response.getheader(h))
15print
16sys.stdout.write(response.read())
18if 200 <= response.status <= 299:
19 sys.exit(0)
20sys.exit(1)
+
+ + + + + + + +% hgweb fileannotate +200 Script output follows + + + + + + + + + +test: get-with-headers.py annotate + + + + + +

Annotate get-with-headers.py

+ + + + + + + + + + + + + + + + + + + + +
changeset 0:79ee608ca36d
author:test
date:Thu Jan 01 00:00:00 1970 +0000 (long ago)
permissions:-rwxr-xr-x
description:a
+ +
+ + + +
test@0 1
#!/usr/bin/env python
test@0 2
test@0 3
__doc__ = """This does HTTP get requests given a host:port and path and returns
test@0 4
a subset of the headers plus the body of the result."""
test@0 5
test@0 6
import httplib, sys
test@0 7
headers = [h.lower() for h in sys.argv[3:]]
test@0 8
conn = httplib.HTTPConnection(sys.argv[1])
test@0 9
conn.request("GET", sys.argv[2])
test@0 10
response = conn.getresponse()
test@0 11
print response.status, response.reason
test@0 12
for h in headers:
test@0 13
    if response.getheader(h, None) is not None:
test@0 14
        print "%s: %s" % (h, response.getheader(h))
test@0 15
print
test@0 16
sys.stdout.write(response.read())
test@0 17
test@0 18
if 200 <= response.status <= 299:
test@0 19
    sys.exit(0)
test@0 20
sys.exit(1)
+ + + + + + + +% errors encountered