/test/sample/run.sh
Shell | 84 lines | 63 code | 9 blank | 12 comment | 5 complexity | 1559925416971813b1705a5c1446bbb1 MD5 | raw file
1#!/bin/bash 2# 2010-08-06 Aurelio Jargas 3# 4# Quick tests to spot changes in samples. 5# NOT integrated into main test suite, you must run it alone. 6# 7# Just add the new target sample to SVN-ROOT/samples/ and it will be tested. 8# 9# Tip: regenerate affected samples: 10# cd ../../ && for t in TARGETS; do txt2tags -t $t samples/sample.t2t; done 11 12cd $(dirname "$0") 13 14errors=0 15svn_root='../..' 16txt2tags="$svn_root/txt2tags --no-rc" 17samples_path=$svn_root/samples 18input=$samples_path/sample.t2t 19 20# This filters removes information that may change between conversions, 21# as macro expansions (date) 22filter() { 23 sed ' 24 # remove date from header 25 s,[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9],DATE, 26 # lout escapes / with "/" in headers 27 s,[0-9][0-9]"/"[0-9][0-9]"/"[0-9][0-9][0-9][0-9],DATE, 28 29 # avoids macro expansion differences 30 s/today is [0-9]\{8\}/today is TODAY/ 31 s/which gives: ..-..-..../which gives: TODAY/ 32 # man escapes - with \- 33 s/which gives: ..\\-..\\-..../which gives: TODAY/ 34 35 # avoids image/link path changes (2nd for Lout) 36 s|../../samples/||g 37 s|.."/".."/"samples"/"||g 38 39 # remove version 40 /generated by/ s/txt2tags [0-9.b]\{1,\} /txt2tags / 41 42 # remove cmdline 43 /cmdline: / s/txt2tags .*/txt2tags/ 44 ' $1 45} 46 47for template in $samples_path/sample* 48do 49 output=$(basename "$template") 50 target=$(basename "$template" | cut -d . -f 2) 51 52 test "$target" = 't2t' && continue # ignore sample.t2t 53 54 if test $(basename "$template") = 'sample-slides-80x25.art' 55 then 56 $txt2tags -t $target -i $input -o $output --slides 57 else 58 $txt2tags -t $target -i $input -o $output 59 fi 60 61 diff -u <(filter $template) <(filter $output) > $output.diff 62 63 if test -s $output.diff 64 then 65 errors=1 66 echo $target >> tmp 67 else 68 rm $output.diff 69 rm $output 70 fi 71done 72 73if test $errors -eq 0 74then 75 echo 76 echo "All samples are OK" 77else 78 echo 79 echo "Found errors here:" 80 ls -1 sample* 81 echo 82 echo "Failed targets:" $(cat tmp) 83 rm tmp 84fi