tests/test-highlight
author Christian Ebert <blacktrash@gmx.net>
Sat, 04 Apr 2009 15:14:36 +0200
changeset 7959 5fb6edbf0ab8
parent 7623 03007ad08027
child 8083 29ac24a36ed7
permissions -rwxr-xr-x
tests: guess lexer by filename for recent pygments Recent pygments guess AntlrJavaLexer for the isolatin text, converted to ascii by util.tolocal, which yields class="err". Guess lexer by extension instead.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     1
#!/bin/sh
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     2
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     3
"$TESTDIR/hghave" pygments || exit 80
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     4
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     5
cat <<EOF >> $HGRCPATH
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     6
[extensions]
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
     7
hgext.highlight =
6485
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
     8
[web]
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
     9
pygments_style = friendly
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    10
EOF
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    11
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    12
hg init test
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    13
cd test
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    14
cp $TESTDIR/get-with-headers.py ./
7120
db7557359636 highlight: convert text to local before passing to pygmentize (issue1341)
Christian Ebert <blacktrash@gmx.net>
parents: 7040
diff changeset
    15
db7557359636 highlight: convert text to local before passing to pygmentize (issue1341)
Christian Ebert <blacktrash@gmx.net>
parents: 7040
diff changeset
    16
# check for UnicodeDecodeError with iso-8859-1 file contents
7959
5fb6edbf0ab8 tests: guess lexer by filename for recent pygments
Christian Ebert <blacktrash@gmx.net>
parents: 7623
diff changeset
    17
python -c 'fp = open("isolatin.txt", "w"); fp.write("h\xFCbsch\n"); fp.close();'
7120
db7557359636 highlight: convert text to local before passing to pygmentize (issue1341)
Christian Ebert <blacktrash@gmx.net>
parents: 7040
diff changeset
    18
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    19
hg ci -Ama
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    20
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    21
echo % hg serve
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    22
hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    23
cat hg.pid >> $DAEMON_PIDS
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    24
6987
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    25
echo % hgweb filerevision, html
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    26
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \
7544
c5e37dc38a52 test-hgweb-*: replace "XX years ago" by a fixed string in get-with-headers.py
Gilles Moris <gilles.moris@free.fr>
parents: 7120
diff changeset
    27
    | sed "s/class=\"k\"/class=\"kn\"/g"
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    28
7120
db7557359636 highlight: convert text to local before passing to pygmentize (issue1341)
Christian Ebert <blacktrash@gmx.net>
parents: 7040
diff changeset
    29
echo % hgweb filerevision, html
7959
5fb6edbf0ab8 tests: guess lexer by filename for recent pygments
Christian Ebert <blacktrash@gmx.net>
parents: 7623
diff changeset
    30
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/isolatin.txt') \
7544
c5e37dc38a52 test-hgweb-*: replace "XX years ago" by a fixed string in get-with-headers.py
Gilles Moris <gilles.moris@free.fr>
parents: 7120
diff changeset
    31
    | sed "s/class=\"k\"/class=\"kn\"/g"
7120
db7557359636 highlight: convert text to local before passing to pygmentize (issue1341)
Christian Ebert <blacktrash@gmx.net>
parents: 7040
diff changeset
    32
6987
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    33
echo % hgweb fileannotate, html
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    34
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \
7544
c5e37dc38a52 test-hgweb-*: replace "XX years ago" by a fixed string in get-with-headers.py
Gilles Moris <gilles.moris@free.fr>
parents: 7120
diff changeset
    35
    | sed "s/class=\"k\"/class=\"kn\"/g"
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    36
6987
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    37
echo % hgweb fileannotate, raw
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    38
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py?style=raw') \
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    39
    | sed "s/test@//" > a
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    40
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    41
echo "200 Script output follows" > b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    42
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    43
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    44
hg annotate "get-with-headers.py" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    45
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    46
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    47
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    48
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    49
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    50
diff -u b a
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    51
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    52
echo
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    53
echo % hgweb filerevision, raw
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    54
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py?style=raw') \
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    55
    > a
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    56
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    57
echo "200 Script output follows" > b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    58
echo "" >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    59
hg cat get-with-headers.py >> b
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    60
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    61
diff -u b a
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    62
d09e813b21e3 highlight: only pygmentize for HTML mimetypes
Rocco Rutte <pdmef@gmx.net>
parents: 6863
diff changeset
    63
echo
6485
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    64
echo % hgweb highlightcss friendly
6863
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    65
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    66
head -n 4 out
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    67
rm out
6485
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    68
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    69
echo % errors encountered
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    70
cat errors.log
7623
03007ad08027 tests: use killdaemons.py in test-highlight
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7544
diff changeset
    71
"$TESTDIR/killdaemons.py"
6485
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    72
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    73
# Change the pygments style
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    74
cat > .hg/hgrc <<EOF
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    75
[web]
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    76
pygments_style = fruity
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    77
EOF
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    78
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    79
echo % hg serve again
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    80
hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    81
cat hg.pid >> $DAEMON_PIDS
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    82
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    83
echo % hgweb highlightcss fruity
6863
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    84
"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    85
head -n 4 out
d78d0f9783b8 Fix intermittent broken pipe in test-highlight
Brendan Cully <brendan@kublai.com>
parents: 6485
diff changeset
    86
rm out
6485
938319418d8c highlight: Generate pygments style sheet dynamically
Isaac Jurado <diptongo@gmail.com>
parents: 6355
diff changeset
    87
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    88
echo % errors encountered
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
    89
cat errors.log