xref: /freebsd/contrib/unifdef/scripts/runtests.sh (revision fb3ef04d2028110f06d68b09009f1f2ca0f4128e)
1 #!/bin/sh
2 
3 export PATH="$(pwd):${PATH}"
4 ${1:+cd} ${1:-:}
5 for cmd in *.sh
6 do
7 	printf .
8 	t=${cmd%.sh}
9 
10 	sh ./${cmd} >${t}.out 2>${t}.err
11 	echo $? >${t}.rc
12 
13 	# strip carriage returns from error output
14 	# in case we are trying to run on MinGW
15 	tr -d '
16 ' >${t}.xerr <${t}.err
17 	mv ${t}.xerr ${t}.err
18 
19 	ok=true
20 	for e in out err rc
21 	do
22 		exp=${t}.exp${e}
23 		got=${t}.${e}
24 		if ! cmp -s ${exp} ${got}
25 		then
26 			echo
27 			echo FAILED: ${got}: $(cat ${cmd})
28 			diff -u ${exp} ${got}
29 			ok=false
30 		fi
31 	done
32 
33 	if ${ok}
34 	then rm -f ${t}.out ${t}.err ${t}.rc
35 	else rc=1
36 	fi
37 done
38 echo
39 exit ${rc}
40