run_parser_all.sh 14 KB

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