tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / tap-test-number-0.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # TAP support:
18 #  - a test result numbered as 0 is to be considered out-of-order
19 # This is consistent with the behaviour of the 'prove' utility.
20
21 am_parallel_tests=yes
22 . ./defs || Exit 1
23
24 if test $am_tap_implementation = perl; then
25   $PERL -MTAP::Parser -e 1 \
26     || skip_ "cannot import TAP::Parser perl module"
27   if $PERL -w -e '
28     use warnings FATAL => "all"; use strict;
29     use TAP::Parser;
30     my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"});
31     my $result = $parser->next;
32     $result->is_plan or die "first line is not TAP plan";
33     $result = $parser->next;
34     $result->is_test or die "second line is not TAP test result";
35     my $testno = $result->number;
36     $parser->next and die "unexpected further TAP stream";
37     exit ($testno == 0 ? 0 : 77);
38   '; then
39     : # Nothing to do.
40   elif test $? -eq 77; then
41     skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1'
42   else
43     fatal_ "error analyzing TAP::Parser module for bugs"
44   fi
45 fi
46
47 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
48
49 cat > a.test <<END
50 1..1
51 ok 0
52 END
53
54 cat > b.test <<END
55 1..1
56 not ok 0
57 END
58
59 cat > c.test <<END
60 1..1
61 ok 0 foo # SKIP
62 END
63
64 cat > d.test <<END
65 1..1
66 not ok 0 bar # TODO
67 END
68
69 cat > e.test <<END
70 1..1
71 ok 0 # TODO
72 END
73
74 TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
75   && { cat stdout; Exit 1; }
76 cat stdout
77
78 count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=5
79
80 grep '^ERROR: a\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
81 grep '^ERROR: b\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
82 grep '^ERROR: c\.test 0 foo # OUT-OF-ORDER (expecting 1)$' stdout
83 grep '^ERROR: d\.test 0 bar # OUT-OF-ORDER (expecting 1)$' stdout
84 grep '^ERROR: e\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
85
86 :