diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Renumber the test scripts into themed ranges
t000x the ground the suite stands on: git version, html validity, the cache t01xx page content, one script per page t02xx features that cut across pages: filters, submodule links, dates, limits t03xx defence, the security regressions and the $HOME promise t04xx the helper tools under tools/
Diffstat (limited to 'tests/t0106-diff.sh')
-rwxr-xr-xtests/t0106-diff.sh115
1 file changed, 0 insertions, 115 deletions
diff --git a/tests/t0106-diff.sh b/tests/t0106-diff.sh
deleted file mode 100755
index 175f609..0000000
--- a/tests/t0106-diff.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-
-# The diff page renders the change a commit made, either as unified text or,
-# when dt=1 asks for it, as a side by side table. The first checks read the
-# markup for one added file in the repository the shared setup builds. The
-# rest build small repositories of their own, shaped so the side by side
-# renderer meets the two cases it used to get wrong, a hunk covering a single
-# line and a file where every line changed.
-
-test_description='Check content on diff page'
-. ./setup.sh
-
-test_expect_success 'generate foo/diff' 'cgit_url "foo/diff" >tmp'
-test_expect_success 'find diff header' 'grep "a/file-5 b/file-5" tmp'
-test_expect_success 'find blob link' 'grep "<a href=./foo/tree/file-5?id=" tmp'
-test_expect_success 'find added file' 'grep "new file mode 100644" tmp'
-
-test_expect_success 'find hunk header' '
- grep "<div class=.hunk.>@@ -0,0 +1 @@</div>" tmp
-'
-
-test_expect_success 'find added line' '
- grep "<div class=.add.>+5</div>" tmp
-'
-
-# git writes a hunk length only when the hunk spans more than one line, so the
-# header for a single line reads "@@ -1 +1 @@" with no comma in it. Requiring
-# that comma left those hunks numbered from zero, which dropped the line
-# number link altogether.
-test_expect_success 'set up a repo with single-line hunks' '
- mkrepo repos/hunk1 1 &&
- (
- cd repos/hunk1 &&
- printf "only\n" >one.txt &&
- git add one.txt &&
- git commit -m "add one.txt" &&
- printf "ONLY\n" >one.txt &&
- git commit -am "change one.txt"
- ) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=hunk1" &&
- echo "repo.path=$PWD/repos/hunk1/.git"
- } >hunk1rc &&
- git -C repos/hunk1 diff HEAD~1 HEAD >raw.diff &&
- grep "^@@ -1 +1 @@" raw.diff
-'
-
-test_expect_success 'ssdiff numbers a comma-less hunk from its real line' '
- CGIT_CONFIG="$PWD/hunk1rc" QUERY_STRING="url=hunk1/diff/&dt=1" cgit >tmp &&
- grep "#n1.>1</a>" tmp &&
- ! grep "#n0.>0</a>" tmp
-'
-
-test_expect_success 'ssdiff still numbers a hunk that carries a length' '
- cgit_query "url=foo/diff&dt=1" >tmp &&
- grep "#n1.>1</a>" tmp
-'
-
-# The character level highlight reuses one table across every changed pair, so
-# these lines get shorter as the file goes on and each comparison is smaller
-# than the one before it. That is where a cell left over from the previous
-# pair shows itself, as a del or an add span sitting over the wrong
-# characters.
-test_expect_success 'set up a repo with shrinking changed lines' '
- mkrepo repos/lcs 1 &&
- (
- cd repos/lcs &&
- awk "BEGIN{for(n=120;n>0;n-=3){s=\"\";
- for(i=0;i<n;i++)s=s sprintf(\"%c\",97+(i*7+n)%26); print s}}" >lines.txt &&
- git add lines.txt &&
- git commit -m "add lines.txt" &&
- awk "BEGIN{for(n=120;n>0;n-=3){s=\"\";
- for(i=0;i<n;i++){c=97+(i*7+n)%26; if(i%7==0)c=97+(c-97+5)%26;
- s=s sprintf(\"%c\",c)} print s}}" >lines.txt &&
- git commit -am "change every line"
- ) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "repo.url=lcs" &&
- echo "repo.path=$PWD/repos/lcs/.git"
- } >lcsrc
-'
-
-test_expect_success 'every changed pair gets both a del and an add span' '
- CGIT_CONFIG="$PWD/lcsrc" QUERY_STRING="url=lcs/diff/&dt=1" cgit >tmp &&
- deletions=$(grep -o "<span class=.del.>" tmp | wc -l) &&
- additions=$(grep -o "<span class=.add.>" tmp | wc -l) &&
- test "$deletions" -gt 0 &&
- test "$deletions" -eq "$additions"
-'
-
-test_expect_success 'stripping the highlight leaves every line intact' '
- sed -e "s/<[^>]*>//g" tmp >plain.out &&
- git -C repos/lcs show HEAD~1:lines.txt >old.txt &&
- git -C repos/lcs show HEAD:lines.txt >new.txt &&
- while read -r line
- do
- grep -qF "$line" plain.out || {
- echo "missing old line: $line"
- return 1
- }
- done <old.txt &&
- while read -r line
- do
- grep -qF "$line" plain.out || {
- echo "missing new line: $line"
- return 1
- }
- done <new.txt
-'
-
-test_done