Update French translation
[gtk-doc.git] / tests / sanity.sh
blobf35c7bbe1626dc9d956da6674545a9ad0fd0cf62
1 #!/bin/sh
3 suite=$1
4 dir=$BUILDDIR
6 failed=0
7 tested=0
9 echo "Running suite(s): gtk-doc-sanity $suite";
11 # check the presence and non-emptyness of certain files
12 nok=0
13 for path in $dir/$suite/docs/html; do
14 if test ! -s $path/index.html ; then
15 echo 1>&2 "no or empty $path/index.html"
16 nok=`expr $nok + 1`; break;
18 if test ! -s $path/home.png ; then
19 echo 1>&2 "no or empty $path/home.png"
20 nok=`expr $nok + 1`; break;
22 file=`echo $path/*.devhelp2`
23 if test ! -s $file ; then
24 echo 1>&2 "no or empty $file"
25 nok=`expr $nok + 1`; break;
27 done
28 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
29 tested=`expr $tested + 1`
31 # TODO: if we have pdf support check for ./tests/$suite/docs/tester.pdf
32 nok=0
33 for path in $dir/$suite/docs; do
34 if test ! -s $path/tester.pdf ; then
35 if test -s $path/gtkdoc-mkpdf.log; then
36 if ! grep >/dev/null 2>&1 "must be installed to use gtkdoc-mkpdf" $path/gtkdoc-mkpdf.log; then
37 echo 1>&2 "no or empty $path/tester.pdf"
38 nok=`expr $nok + 1`; break;
42 done
43 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
44 tested=`expr $tested + 1`
46 # check validity of generated xml files
47 nok=0
48 for file in $dir/$suite/docs/xml/*.xml; do
49 xmllint --noout --noent $file
50 if test $? != 0 ; then
51 echo 1>&2 "xml validity check failed for $file"
52 nok=`expr $nok + 1`;
54 done
55 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
56 tested=`expr $tested + 1`
59 # check validity of generated sgml files
60 nok=0
61 for file in $dir/$suite/docs/xml/*.sgml; do
62 xmllint --noout --noent $file
63 if test $? != 0 ; then
64 echo 1>&2 "sgml validity check failed for $file"
65 nok=`expr $nok + 1`;
67 done
68 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
69 tested=`expr $tested + 1`
71 # check validity of devhelp2 files
72 nok=0
73 for file in $dir/$suite/docs/html/*.devhelp2; do
74 xmllint --noout --nonet --schema $ABS_TOP_SRCDIR/devhelp2.xsd $file
75 if test $? != 0 ; then
76 echo 1>&2 "devhelp2 xml validity check failed for $file"
77 nok=`expr $nok + 1`;
79 done
80 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
81 tested=`expr $tested + 1`
83 # check that log files have only one line (the command)
84 # discard references to launchapd bugs
85 nok=0
86 DISCARD_PATTERN='Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/[0-9]* . For now run:
87 gunzip .*.gz
90 for file in $dir/$suite/docs/gtkdoc-*.log; do
91 # skip this in verbose mode as we'll have more text
92 if test "x${V}" = "x1"; then
93 continue
96 expected_lines="1"
97 # adjust for known files
98 if test $file = "$dir/bugs/docs/gtkdoc-mkdb.log"; then
99 expected_lines="2"
101 if test $file = "$dir/gobject/docs/gtkdoc-fixxref.log"; then
102 expected_lines="2"
104 case $file in
105 *gtkdoc-fixxref.log)
106 # if there is no /usr/share/gtk-doc/html/gobject we should skip fixxref logs
107 if test ! -d "$GLIB_PREFIX/share/gtk-doc/html/gobject"; then
108 continue
111 esac
113 lines=`grep -v -x -G -e "$DISCARD_PATTERN" $file | wc -l | cut -d' ' -f1`
114 if test $lines -gt $expected_lines; then
115 echo 1>&2 "expected no more than $expected_lines log line in $file, but got $lines"
116 nok=`expr $nok + 1`;
118 done
119 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
120 tested=`expr $tested + 1`
122 # check stability of generated xml/html
123 nok=0
124 for path in $dir/$suite/docs*; do
125 if test -d $path/xml.ref; then
126 diff -u $path/xml.ref $path/xml
127 if test $? = 1 ; then
128 echo 1>&2 "difference in generated xml for $path"
129 nok=`expr $nok + 1`;
132 if test -d $path/html.ref; then
133 diff -u $path/html.ref $path/html
134 if test $? = 1 ; then
135 echo 1>&2 "difference in generated html for $path"
136 nok=`expr $nok + 1`;
139 done
140 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
141 tested=`expr $tested + 1`
144 # summary
145 successes=`expr $tested - $failed`
146 rate=`expr 100 \* $successes / $tested`;
147 echo "$rate %: Checks $tested, Failures: $failed"
149 test $failed = 0
150 exit $?