1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
test_description='Validate html with tidy'
. ./setup.sh
tidy_page() {
strip_headers <"$1.out" >"$1" &&
test -s "$1" || return 1
tidy -eq "$1"
test $? != 2
}
test_url() {
tidy_file=tidy-$(printf '%s' "${1:-index}" | tr / -) &&
if test -n "$2"
then
cgit_ok "$2" "url=$1"
else
cgit_ok_url "$1"
fi >"$tidy_file.out" &&
tidy_page "$tidy_file"
}
test_lazy_prereq TIDY '
cat >probe.html <<-\EOF &&
<!DOCTYPE html>
<html lang="en"><head><title>t</title></head><body><header>x</header></body></html>
EOF
tidy -q -e probe.html >/dev/null 2>&1
test $? -lt 2
'
test_have_prereq TIDY || {
skip_all='Skipping html validation tests: no tidy that knows HTML5'
test_done
}
test_expect_success 'index page' 'test_url ""'
test_expect_success 'foo' 'test_url "foo"'
test_expect_success 'foo/log' 'test_url "foo/log"'
test_expect_success 'foo/tree' 'test_url "foo/tree"'
test_expect_success 'foo/tree/file-1' 'test_url "foo/tree/file-1"'
test_expect_success 'foo/commit' 'test_url "foo/commit"'
test_expect_success 'foo/diff' 'test_url "foo/diff"'
test_expect_success 'foo/refs' 'test_url "foo/refs"'
test_expect_success 'error page' '
cgit_url "no-such-repo" >tidy-error.out &&
grep "^Status: 404" tidy-error.out &&
tidy_page tidy-error
'
test_expect_success 'set up a features config' '
cgitrc_repo featrc feat max-stats=year enable-blame=1 "repo.path=$PWD/repos/foo/.git"
'
test_expect_success 'stats page' 'test_url "feat/stats/" featrc'
test_expect_success 'blame page' 'test_url "feat/blame/file-1" featrc'
test_done
|