mkhtml2: improve chunking to handle tocs
[gtk-doc.git] / tests / sanity.sh
blob5a79f1805c5d512c3f6604638982fb49d3c45080
1 #!/bin/sh
3 dir=$BUILDDIR
4 #`dirname $0`
5 suite="sanity"
7 failed=0
8 tested=0
10 echo "Running suite(s): gtk-doc-$suite";
12 # check the presence and non-emptyness of certain files
13 nok=0
14 for path in $dir/*/docs/html; do
15 if test ! -s $path/index.html ; then
16 echo 1>&2 "no or empty $path/index.html"
17 nok=`expr $nok + 1`; break;
19 if test ! -s $path/home.png ; then
20 echo 1>&2 "no or empty $path/home.png"
21 nok=`expr $nok + 1`; break;
23 file=`echo $path/*.devhelp2`
24 if test ! -s $file ; then
25 echo 1>&2 "no or empty $file"
26 nok=`expr $nok + 1`; break;
28 done
29 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
30 tested=`expr $tested + 1`
32 # TODO: if we have pdf support check for ./tests/*/docs/tester.pdf
33 nok=0
34 for path in $dir/*/docs; do
35 if test ! -s $path/tester.pdf ; then
36 if test -s $path/gtkdoc-mkpdf.log; then
37 if ! grep >/dev/null 2>&1 "must be installed to use gtkdoc-mkpdf" $path/gtkdoc-mkpdf.log; then
38 echo 1>&2 "no or empty $path/tester.pdf"
39 nok=`expr $nok + 1`; break;
43 done
44 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
45 tested=`expr $tested + 1`
47 # check validity of generated xml files
48 nok=0
49 for file in $dir/*/docs/xml/*.xml; do
50 xmllint --noout --noent $file
51 if test $? != 0 ; then
52 echo 1>&2 "xml validity check failed for $file"
53 nok=`expr $nok + 1`;
55 done
56 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
57 tested=`expr $tested + 1`
60 # check validity of generated sgml files
61 nok=0
62 for file in $dir/*/docs/xml/*.sgml; do
63 xmllint --noout --noent $file
64 if test $? != 0 ; then
65 echo 1>&2 "sgml validity check failed for $file"
66 nok=`expr $nok + 1`;
68 done
69 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
70 tested=`expr $tested + 1`
72 # check validity of devhelp2 files
73 nok=0
74 for file in $dir/*/docs/html/*.devhelp2; do
75 xmllint --noout --nonet --schema $ABS_TOP_SRCDIR/devhelp2.xsd $file
76 if test $? != 0 ; then
77 echo 1>&2 "devhelp2 xml validity check failed for $file"
78 nok=`expr $nok + 1`;
80 done
81 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
82 tested=`expr $tested + 1`
84 # check that log files have only one line (the command)
85 # discard references to launchapd bugs
86 nok=0
87 DISCARD_PATTERN='Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/[0-9]* . For now run:
88 gunzip .*.gz
91 for file in $dir/*/docs/gtkdoc-*.log; do
92 # skip this in verbose mode as we'll have more text
93 if test "x${V}" = "x1"; then
94 continue
97 expected_lines="1"
98 # adjust for known files
99 if test $file = "$dir/fail/docs/gtkdoc-mkdb.log"; then
100 expected_lines="16"
102 if test $file = "$dir/bugs/docs/gtkdoc-mkdb.log"; then
103 expected_lines="2"
105 if test $file = "$dir/gobject/docs/gtkdoc-fixxref.log"; then
106 expected_lines="2"
108 case $file in
109 *gtkdoc-fixxref.log)
110 # if there is no /usr/share/gtk-doc/html/gobject we should skip fixxref logs
111 if test ! -d "$GLIB_PREFIX/share/gtk-doc/html/gobject"; then
112 continue
115 esac
117 lines=`grep -v -x -G -e "$DISCARD_PATTERN" $file | wc -l | cut -d' ' -f1`
118 if test $lines -gt $expected_lines; then
119 echo 1>&2 "expected no more than $expected_lines log line in $file, but got $lines"
120 nok=`expr $nok + 1`;
122 done
123 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
124 tested=`expr $tested + 1`
126 # check stability of generated xml/html
127 nok=0
128 for path in $dir/*/docs*; do
129 if test -d $path/xml.ref; then
130 diff -u $path/xml.ref $path/xml
131 if test $? = 1 ; then
132 echo 1>&2 "difference in generated xml for $path"
133 nok=`expr $nok + 1`;
136 if test -d $path/html.ref; then
137 diff -u $path/html.ref $path/html
138 if test $? = 1 ; then
139 echo 1>&2 "difference in generated html for $path"
140 nok=`expr $nok + 1`;
143 done
144 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
145 tested=`expr $tested + 1`
148 # summary
149 successes=`expr $tested - $failed`
150 rate=`expr 100 \* $successes / $tested`;
151 echo "$rate %: Checks $tested, Failures: $failed"
153 test $failed = 0
154 exit $?