diff options
Diffstat (limited to '')
| -rwxr-xr-x | tests/t0005-markup.sh | 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0104-tree.sh | 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 62 insertions, 4 deletions
diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index e3cb08d..829c839 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -96,15 +96,17 @@ test_expect_success 'the stylesheet and the script name only the current hooks' grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js" ' -# The rest of the hooks need a tag, a symlink, a submodule, a trailer, clone -# urls, an empty repository and a second page of repositories, so they get a -# commit and a config of their own after the checks above have read the first -# ones. +# The rest of the hooks need a tag, a symlink, a submodule, a trailer, a lone +# carriage return, clone urls, an empty repository and a second page of +# repositories, so they get a commit and a config of their own after the checks +# above have read the first ones. test_expect_success 'set up the remaining kinds of entry' ' ( cd repos/hooks && git tag -a -m "first release" v1 && test_ln_s_add file-1 link && + printf "a\\rb\\n" >cr.txt && + git add cr.txt && git update-index --add --cacheinfo "160000,$(git rev-parse HEAD),sub" && git commit -m "more kinds of entry" -m "Fixes: $(git rev-parse --short HEAD)" ) && @@ -139,6 +141,11 @@ test_expect_success 'the refs, summary and tree name every section and row' ' grep "<tr class=.mod.>" tmp ' +test_expect_success 'a character the browser would break a line at is an escape' ' + more "hooks/tree/cr.txt" >tmp && + grep "a<span class=.escape.>" tmp +' + test_expect_success 'the commit page has its trailer table and diffstat' ' more "hooks/commit/" >tmp && grep "<table class=.commit-trailers.>" tmp && diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index fefff4a..d464f8c 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -31,6 +31,57 @@ test_expect_success 'the code is set in the font of its line numbers' ' grep "^ font: inherit;$" rule ' +# A browser starts a new line at more characters than git ends one at, and +# each would push the rest of the code a line below its numbers. +test_expect_success 'set up a file holding the characters a browser breaks at' ' + test_create_repo repos/breaks && + ( + cd repos/breaks && + printf "a\\rb\\vc\\fd\\302\\205e\\342\\200\\250f\\342\\200\\251g\\nh\\r\\ni\\r" >breaks.txt && + git add breaks.txt && + git commit -m breaks + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-blame=1" && + echo "repo.url=breaks" && + echo "repo.path=$PWD/repos/breaks/.git" + } >breaksrc +' + +test_expect_success 'each of them is shown as an escape in the tree' ' + CGIT_CONFIG="$PWD/breaksrc" QUERY_STRING="url=breaks/tree/breaks.txt" cgit >tmp && + grep "<code>a<span class=.escape.>\\\\r</span>b<span class=.escape.>\\\\v</span>c" tmp && + grep "c<span class=.escape.>\\\\f</span>d<span class=.escape.>\\\\u0085</span>e" tmp && + grep "e<span class=.escape.>\\\\u2028</span>f<span class=.escape.>\\\\u2029</span>g$" tmp +' + +test_expect_success 'only a carriage return before a line feed is left as it is' ' + printf "h\\r\\n" >expect && + grep "^h" tmp >actual && + test_cmp expect actual && + grep "^i<span class=.escape.>\\\\r</span></code>" tmp +' + +test_expect_success 'the numbers count only the lines git counts' ' + grep "<a id=.n3. href=.#n3.>3</a>" tmp && + ! grep "<a id=.n4. href=.#n4.>4</a>" tmp +' + +test_expect_success 'the blame page escapes them the same way' ' + CGIT_CONFIG="$PWD/breaksrc" QUERY_STRING="url=breaks/blame/breaks.txt" cgit >tmp && + grep "<code>a<span class=.escape.>\\\\r</span>b<span class=.escape.>\\\\v</span>c" tmp && + grep "e<span class=.escape.>\\\\u2028</span>f<span class=.escape.>\\\\u2029</span>g$" tmp && + grep "^i<span class=.escape.>\\\\r</span></code>" tmp +' + +# The striped background is padded with spaces to the widest line, which is +# 31 columns once its six escapes are written out, though it is 18 bytes. +test_expect_success 'the blame stripes are as wide as the escaped line' ' + grep "^ \\{31\\}</pre></div>" tmp +' + test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp' test_expect_success 'verify a+b link' ' |
