tests: work around strangeness in MSYS
[automake.git] / tests / tap-realtime.test
blobdd4621ce0940243fb930a8b88b307cde54fda12e
1 #! /bin/sh
2 # Copyright (C) 2011 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # TAP support:
18 # - testsuite progress on console should happen mostly "in real time";
19 # i.e., it's not acceptable for the driver to wait the end of the
20 # script to start displaying results from it.
21 # FIXME: this test uses expect(1) to ensure line buffering from make and
22 # children, and is pretty hacky and complex; is there a better way to
23 # accomplish the checks done here?
25 am_parallel_tests=yes
26 . ./defs || Exit 1
28 cat >expect-check <<'END'
29 eval spawn $env(SHELL) -c ":"
30 expect eof
31 END
32 expect -f expect-check || {
33 echo "$me: failed to find a working expect program" >&2
34 Exit 77
36 rm -f expect-check
38 cat > Makefile.am << 'END'
39 TESTS = all.test
40 END
41 . "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
43 cat > all.test <<'END'
44 #! /bin/sh
45 echo 1..3
47 # Creative quoting to placate maintainer-check
48 sleep="sleep "3
50 # The awk+shell implementation of the TAP driver must "read ahead" of one
51 # line in order to catch the exit status of the test script it runs. So
52 # be sure to echo one "dummy" line after each result line in order not to
53 # cause false positives.
55 echo ok 1 - foo
56 echo DUMMY
57 $sleep
58 test -f ok-1 || { echo 'Bail out!'; exit 1; }
60 echo ok 2 - bar
61 echo DUMMY
62 $sleep
63 test -f ok-2 || { echo 'Bail out!'; exit 1; }
65 echo ok 3 - baz
66 echo DUMMY
67 $sleep
68 test -f ok-3 || { echo 'Bail out!'; exit 1; }
70 : > all-is-well
71 END
73 chmod a+x all.test
75 cat > expect-make <<'END'
76 eval spawn $env(MAKE) check
77 expect {
78 "PASS: all.test 1 - foo" {
79 open "ok-1" "w"
80 exp_continue
82 "PASS: all.test 2 - bar" {
83 open "ok-2" "w"
84 exp_continue
86 "PASS: all.test 3 - baz" {
87 open "ok-3" "w"
88 exp_continue
90 "Testsuite summary" {
91 exit 0
93 timeout {
94 puts "expect timed out"
95 exit 1
97 default {
98 puts "expect error"
99 exit 1
104 # Expect should simulate a tty as stdout, which should ensure a
105 # line-buffered output.
106 MAKE=$MAKE expect -f expect-make
107 test -f all-is-well