run_test_all.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #! /bin/sh
  2. # Copyright (C) 2010 Free Software Foundation, Inc.
  3. #
  4. # Copying and distribution of this file, with or without modification,
  5. # are permitted in any medium without royalty provided the copyright
  6. # notice and this notice are preserved.
  7. #set -x
  8. #echo "SRCDIR $srcdir srcdir_test $srcdir_test"
  9. LC_ALL=C; export LC_ALL
  10. res_dir=res
  11. out_dir=out
  12. command=texi2html.pl
  13. diffs_dir=diffs
  14. logfile=tests.log
  15. main_command='texi2any.pl'
  16. commands='texi2html.pl: makeinfo.pl:_info texi2any.pl:_all'
  17. clean=no
  18. if [ z"$1" = 'z-clean' ]; then
  19. clean=yes
  20. shift
  21. fi
  22. copy=no
  23. if [ z"$1" = 'z-copy' ]; then
  24. [ -d "$res_dir" ] || mkdir "$res_dir"
  25. copy=yes
  26. shift
  27. fi
  28. no_latex2html=yes
  29. if which latex2html > /dev/null 2>&1; then
  30. no_latex2html=no
  31. fi
  32. no_tex4ht=yes
  33. if which httexi > /dev/null 2>&1; then
  34. no_tex4ht=no
  35. fi
  36. no_html2wiki=yes
  37. if which html2wiki > /dev/null 2>&1; then
  38. no_html2wiki=no
  39. fi
  40. one_test=no
  41. if [ z"$1" != 'z' ]; then
  42. one_test=yes
  43. the_test=$1
  44. if [ "z$the_test" = "ztexi" ]; then
  45. the_file=$2
  46. [ "z$the_file" != "z" ] && the_basename=`basename $the_file .texi`
  47. fi
  48. fi
  49. if [ "z$srcdir_test" = 'z' ]; then
  50. testdir=.
  51. srcdir_test=.
  52. else
  53. if [ "z$srcdir" = 'z' ]; then
  54. testdir=..
  55. else
  56. testdir=../$srcdir
  57. fi
  58. fi
  59. base_results_dir="$testdir/$srcdir_test"
  60. test_file='tests.txt'
  61. driving_file="$testdir/$srcdir_test/$test_file"
  62. if [ -f "$driving_file" ]; then
  63. :
  64. else
  65. echo "Cannot find test driving file $driving_file" 1>&2
  66. exit 1
  67. fi
  68. first_line=`head -1 "$driving_file"`
  69. if echo $first_line |grep -qs '^# formats'; then
  70. formats=`echo $first_line |sed 's/^# formats //'`
  71. commands="$commands $formats"
  72. fi
  73. if [ "z$clean" = 'zyes' -o "z$copy" = 'zyes' ]; then
  74. while read line
  75. do
  76. if echo $line | grep -qs '^ *#'; then continue; fi
  77. # there are better ways
  78. dir=`echo $line | awk '{print $1}'`
  79. file=`echo $line | awk '{print $2}'`
  80. remaining=`echo $line | sed 's/[a-zA-Z0-9_./-]\+ \+[a-zA-Z0-9_./-]\+ *//'`
  81. [ "z$dir" = 'z' -o "$zfile" = 'z' ] && continue
  82. basename=`basename $file .texi`
  83. if [ "z$dir" = 'ztexi' ]; then
  84. dir="texi_${basename}"
  85. fi
  86. if [ "z$clean" = 'zyes' ]; then
  87. for command_dir in $commands; do
  88. dir_suffix=`echo $command_dir | cut -d':' -f2`
  89. outdir="${out_dir}${dir_suffix}/"
  90. [ -d "${outdir}$dir" ] && rm -rf "${outdir}$dir"
  91. done
  92. else
  93. for command_dir in $commands; do
  94. dir_suffix=`echo $command_dir | cut -d':' -f2`
  95. outdir="${out_dir}${dir_suffix}/"
  96. resdir="${res_dir}${dir_suffix}/"
  97. if [ -d "$resdir" ]; then
  98. :
  99. else
  100. mkdir "$resdir"
  101. fi
  102. if [ -d "${outdir}$dir" ]; then
  103. if [ -d "${resdir}$dir" ]; then
  104. # ugly hack to avoid CVS and .svn
  105. rm -f "${resdir}$dir/"?*.*
  106. else
  107. mkdir "${resdir}$dir/"
  108. fi
  109. cp -r "${outdir}$dir/"* "${resdir}$dir/"
  110. rm -f "${resdir}$dir/"*.png "${resdir}$dir/"*_l2h.css
  111. else
  112. echo "No dir ${outdir}$dir" 1>&2
  113. fi
  114. done
  115. fi
  116. done < "$driving_file"
  117. exit 0
  118. fi
  119. . ../path_separator || exit 1
  120. [ -d "$diffs_dir" ] || mkdir "$diffs_dir"
  121. for command_dir in $commands; do
  122. dir_suffix=`echo $command_dir | cut -d':' -f2`
  123. outdir="${out_dir}${dir_suffix}/"
  124. [ -d "${outdir}" ] || mkdir "${outdir}"
  125. done
  126. if tmp_dir=`mktemp -p /tmp -d l2h_t2h_XXXXXXXX`; then
  127. :
  128. else
  129. exit 1
  130. fi
  131. echo "base_result_dir $base_results_dir, driving_file $driving_file" > $logfile
  132. return_code=0
  133. while read line
  134. do
  135. if echo $line | grep -qs '^ *#'; then continue; fi
  136. # there are better ways
  137. current=`echo $line | awk '{print $1}'`
  138. file=`echo $line | awk '{print $2}'`
  139. [ "z$current" = 'z' -o "$zfile" = 'z' ] && continue
  140. basename=`basename $file .texi`
  141. remaining=`echo $line | sed 's/[a-zA-Z0-9_./-]\+ \+[a-zA-Z0-9_./-]\+ *//' | sed 's,@PATH_SEPARATOR@,'"${PATH_SEPARATOR}$testdir/$srcdir_test/"',g'`
  142. src_file="$testdir/$srcdir_test/$file"
  143. if [ $one_test = 'yes' -a "z$current" != "z$the_test" ]; then
  144. continue
  145. fi
  146. for command_dir in $commands; do
  147. format_option=
  148. command=`echo $command_dir | cut -d':' -f1`
  149. dir_suffix=`echo $command_dir | cut -d':' -f2`
  150. format=`echo $dir_suffix |sed 's/^_//'`
  151. if [ z"$command" = 'z' ]; then
  152. command=$main_command
  153. format_option="--$format"
  154. fi
  155. command_run=
  156. for command_location_dir in "$testdir/$srcdir_test/../../" ../../; do
  157. if [ -f "$command_location_dir/$command" ]; then
  158. command_run="$command_location_dir/$command"
  159. break
  160. fi
  161. done
  162. if [ z"$command_run" = 'z' ]; then
  163. echo "Command $command not found"
  164. exit 1
  165. fi
  166. export T2H_HOME="`pwd`""/$testdir/$srcdir_test/../../"
  167. outdir="${out_dir}${dir_suffix}/"
  168. results_dir="$testdir/$srcdir_test/${res_dir}${dir_suffix}"
  169. if [ "z$current" = 'ztexi' ]; then
  170. if [ $one_test = 'yes' -a "z$the_basename" != 'z' -a "z$basename" != "z$the_basename" ]; then
  171. continue 2
  172. fi
  173. one_test_done=yes
  174. dir="texi_${basename}"
  175. [ -d "${outdir}$dir" ] && rm -rf "${outdir}$dir"
  176. mkdir "${outdir}$dir"
  177. remaining_out_dir=`echo $remaining | sed 's,@OUT_DIR@,'"${outdir}$dir/"',g'`
  178. command_file=
  179. # -I $testdir/$srcdir_test/ is useful when file name is found using
  180. # @setfilename
  181. echo "$command $dir" >> $logfile
  182. echo "perl -w -x $command_run $format_option --force --conf-dir $testdir/$srcdir_test/../../maintained_extra --conf-dir $testdir/$srcdir_test/../../examples --conf-dir $testdir/$srcdir_test/../../formats --conf-dir $testdir/$srcdir_test/ --conf-dir $testdir/$srcdir_test/../ --error-limit=1000 --set-init-var TEST=1 --output ${outdir}$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ --set-init-var=DUMP_TEXI=1 --macro-expand=${outdir}$dir/$basename.texi $remaining_out_dir $src_file 2>${outdir}$dir/$basename.2" >> $logfile
  183. eval "perl -w -x $command_run $format_option --force --conf-dir $testdir/$srcdir_test/../../maintained_extra --conf-dir $testdir/$srcdir_test/../../examples --conf-dir $testdir/$srcdir_test/../../formats --conf-dir $testdir/$srcdir_test/ --conf-dir $testdir/$srcdir_test/../ --error-limit=1000 --set-init-var TEST=1 --output ${outdir}$dir/ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ --set-init-var=DUMP_TEXI=1 --macro-expand=${outdir}$dir/$basename.texi $remaining_out_dir $src_file 2>${outdir}$dir/$basename.2"
  184. ret=$?
  185. else
  186. one_test_done=yes
  187. use_latex2html=no
  188. use_tex4ht=no
  189. l2h_tmp_dir=
  190. maybe_use_latex2html=no
  191. if echo "$remaining" | grep -qs -- '-l2h'; then
  192. maybe_use_latex2html=yes
  193. fi
  194. if echo "$remaining" | grep -qs -- 'L2H 1'; then
  195. maybe_use_latex2html=yes
  196. fi
  197. if [ $maybe_use_latex2html = 'yes' ]; then
  198. if [ "$no_latex2html" = 'yes' ]; then
  199. echo "S: (no latex2html) $current"
  200. continue 2
  201. fi
  202. use_latex2html=yes
  203. l2h_tmp_dir="--set-init-var 'L2H_TMP $tmp_dir'"
  204. elif echo "$remaining" | grep -qs -- '-init tex4ht.pm'; then
  205. if [ "$no_tex4ht" = 'yes' ]; then
  206. echo "S: (no tex4ht) $current"
  207. continue 2
  208. fi
  209. use_tex4ht=yes
  210. fi
  211. if [ $use_tex4ht = 'yes' -o $use_latex2html = 'yes' ]; then
  212. if echo "$remaining" | grep -qs -- '-init mediawiki.pm'; then
  213. if [ "$no_html2wiki" = 'yes' ]; then
  214. echo "S: (no html2wiki) $current"
  215. continue 2
  216. fi
  217. fi
  218. fi
  219. dir=$current
  220. [ -d "${outdir}$dir" ] && rm -rf "${outdir}$dir"
  221. mkdir "${outdir}$dir"
  222. remaining_out_dir=`echo $remaining | sed 's,@OUT_DIR@,'"${outdir}$dir/"',g'`
  223. echo "$command $dir" >> $logfile
  224. echo "perl -w -x $command_run $format_option --force --conf-dir $testdir/$srcdir_test/../../maintained_extra --conf-dir $testdir/$srcdir_test/../../examples --conf-dir $testdir/$srcdir_test/../../formats --conf-dir $testdir/$srcdir_test/ --conf-dir $testdir/$srcdir_test/../ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ --set-init-var L2H_FILE=$testdir/$srcdir_test/../../examples/l2h.init --error-limit=1000 --set-init-var TEST=1 --set-init-var L2H_CLEAN=0 $l2h_tmp_dir --output ${outdir}$dir/ $remaining_out_dir $src_file > ${outdir}$dir/$basename.1 2>${outdir}$dir/$basename.2" >> $logfile
  225. eval "perl -w -x $command_run $format_option --force --conf-dir $testdir/$srcdir_test/../../maintained_extra --conf-dir $testdir/$srcdir_test/../../examples --conf-dir $testdir/$srcdir_test/../../formats --conf-dir $testdir/$srcdir_test/ --conf-dir $testdir/$srcdir_test/../ -I $testdir/$srcdir_test/ -I $testdir/$srcdir_test/../ --set-init-var L2H_FILE=$testdir/$srcdir_test/../../examples/l2h.init --error-limit=1000 --set-init-var TEST=1 --set-init-var L2H_CLEAN=0 $l2h_tmp_dir --output ${outdir}$dir/ $remaining_out_dir $src_file > ${outdir}$dir/$basename.1 2>${outdir}$dir/$basename.2"
  226. ret=$?
  227. # *_l2h_images.pl has not reproducible cached entries
  228. rm -f ${outdir}$dir/*_l2h_images.log ${outdir}$dir/*_l2h_images.pl \
  229. ${outdir}$dir/*_tex4ht_*.log \
  230. ${outdir}$dir/*_tex4ht_*.idv ${outdir}$dir/*_tex4ht_*.dvi \
  231. ${outdir}$dir/*_tex4ht_tex.html* ${outdir}$dir/*_l2h.html.*
  232. fi
  233. if [ $ret = 0 ]; then
  234. diff_base="${dir}${dir_suffix}"
  235. sed -i -e 's/^texexpand.*/texexpand /' "${outdir}$dir/$basename.2"
  236. sed -i '/is no longer supported at.*line/d' "${outdir}$dir/$basename.2"
  237. if [ "$use_latex2html" = 'yes' ]; then
  238. # in case the output format is not html there won't be "*"_l2h.html files
  239. for file in "${outdir}$dir/"*"_l2h.html"; do
  240. if [ -f "$file" ]; then
  241. sed -i -e 's/CONTENT="LaTeX2HTML.*/CONTENT="LaTeX2HTML">/' -e \
  242. 's/with LaTeX2HTML.*/with LaTeX2HTML/' "$file"
  243. fi
  244. done
  245. # "*"_images.pl" files are not guaranteed to be present
  246. for file in "${outdir}$dir/"*"_images.pl" "${outdir}$dir/"*"_labels.pl"; do
  247. if [ -f "$file" ]; then
  248. sed -i -e 's/^# LaTeX2HTML.*/# LaTeX2HTML/' "$file"
  249. fi
  250. done
  251. for file in "${outdir}$dir/"*.htm* "${outdir}$dir/"*-l2h_cache.pm "${outdir}$dir/"*_l2h_images.pl; do
  252. if [ -f "$file" ]; then
  253. # different rounding on different computers !
  254. sed -i -e 's/WIDTH="\([0-9]*\)\([0-9]\)"/WIDTH="100"/' -e 's/HEIGHT="\([0-9]*\)\([0-9]\)"/HEIGHT="\10"/' "$file"
  255. fi
  256. done
  257. rm -f "${outdir}$dir/"*".aux" "${outdir}$dir/"*"_images.out"
  258. fi
  259. if [ "$use_latex2html" = 'yes' -o "$use_tex4ht" = 'yes' ]; then
  260. rm -f "${outdir}$dir/$basename.1"
  261. fi
  262. if [ -d "$results_dir/$dir" ]; then
  263. diff -a -u --exclude=CVS --exclude=.svn --exclude='*.png' --exclude='*_l2h.css' -r "$results_dir/$dir" "${outdir}$dir" 2>>$logfile > "$diffs_dir/$diff_base.diff"
  264. dif_ret=$?
  265. if [ $dif_ret != 0 ]; then
  266. echo "D: $diffs_dir/$diff_base.diff"
  267. return_code=1
  268. else
  269. rm "$diffs_dir/$diff_base.diff"
  270. fi
  271. else
  272. echo "no res($format): $dir"
  273. fi
  274. else
  275. echo "F: ${outdir}$dir/$basename.2"
  276. return_code=1
  277. fi
  278. done
  279. done < "$driving_file"
  280. rm -rf $tmp_dir
  281. if [ "$one_test" = 'yes' -a "z$one_test_done" != "zyes" ]; then
  282. echo "$the_test $the_file test not found"
  283. fi
  284. exit $return_code