* doc/m4.texinfo (Changeword): Skip test on mingw, where the
[m4.git] / checks / check-them
blob105d4e3e64c0496f2b8c6dc6b61a137668a1997c
1 #!/bin/sh
2 # Check GNU m4 against examples from the manual source.
3 # Copyright (C) 1992, 2006 Free Software Foundation, Inc.
5 # Sanity check what we are testing
6 m4 --version
8 # Clean up temp files on exit
9 pwd=`pwd`
10 tmp=m4-tmp.$$
11 trap 'stat=$?; cd $pwd; rm -rf $tmp && exit $stat' 0
12 trap '(exit $?); exit $?' 1 2 13 15
14 # Create scratch dir
15 framework_failure=0
16 mkdir $tmp || framework_failure=1
18 if test $framework_failure = 1; then
19 echo "$0: failure in testing framework" 1>&2
20 (exit 1); exit 1
23 out=$tmp/m4-out
24 err=$tmp/m4-err
25 xout=$tmp/m4-xout
26 xerr=$tmp/m4-xerr
27 failed=
28 skipped=
29 strip_needed=false
31 # Find out how the executable prints argv[0]
32 m4=`m4 --help | sed -e 's/Usage: \(.*\) \[OPTION.*/\1/' \
33 -e 's/\\\\/\\\\\\\\/g' -e 1q`
35 # Find out if we should strip \r in the output
36 m4 --version > $out
37 m4 --version | tr -d '\015' > $xout
38 if cmp -s $out $xout; then
40 else
41 echo "Ignoring carriage returns"
42 strip_needed=:
45 # Find out where the examples live.
46 examples=.
47 if test "x$1" = x-I ; then
48 examples="$2"
49 shift; shift
52 # Run the tests.
53 for file
55 test -f "$file" || {
56 echo "No such file: $file"
57 continue
59 echo "Checking $file"
60 sed -e '/^dnl @/d' -e '/^\^D$/q' "$file" \
61 | LC_MESSAGES=C m4 -d -I "$examples" - >$out 2>$err
63 if test $? = 77 ; then
64 skipped="$skipped $file"
65 cat $err
66 continue
69 sed -e '/^dnl @result{}/!d' -e 's///' -e "s|\.\./examples|$examples|" \
70 "$file" > $xout
71 sed -e '/^dnl @error{}/!d' -e 's///' -e "s|^m4:|$m4:|" "$file" > $xerr
73 # For the benefit of mingw, normalize \r\n line endings
74 if $strip_needed ; then
75 tr -d '\015' < $out > $out.t
76 mv $out.t $out
77 tr -d '\015' < $xout > $xout.t
78 mv $xout.t $xout
79 tr -d '\015' < $err > $err.t
80 mv $err.t $err
81 tr -d '\015' < $xerr > $xerr.t
82 mv $xerr.t $xerr
85 if cmp -s $out $xout; then
87 else
88 failed="$failed $file:out"
89 echo `sed -e 's/^dnl //' -e 1q $file`
90 echo "$file: stdout mismatch"
91 diff $xout $out
94 if cmp -s $err $xerr; then
96 else
97 failed="$failed $file:err"
98 echo `sed -e 's/^dnl //' -e 1q $file`
99 echo "$file: stderr mismatch"
100 diff $xerr $err
103 done
105 rm -f $out $err $xout $xerr
107 echo
108 if test -n "$skipped"; then
109 echo "Skipped checks were:"
110 echo " $skipped"
112 if test -z "$failed"; then
113 echo "All checks successful"
114 stat=0
115 else
116 echo "Failed checks were:"
117 echo " $failed"
118 stat=1
120 (exit $stat); exit $stat