am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / tap-test-number-0.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 . test-init.sh
22
23 if test $am_tap_implementation = perl; then
24   $PERL -MTAP::Parser -e 1 \
25     || skip_ "cannot import TAP::Parser perl module"
26   if $PERL -w -e '
27     use warnings FATAL => "all"; use strict;
28     use TAP::Parser;
29     my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"});
30     my $result = $parser->next;
31     $result->is_plan or die "first line is not TAP plan";
32     $result = $parser->next;
33     $result->is_test or die "second line is not TAP test result";
34     my $testno = $result->number;
35     $parser->next and die "unexpected further TAP stream";
36     exit ($testno == 0 ? 0 : 77);
37   '; then
38     : # Nothing to do.
39   elif test $? -eq 77; then
40     skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1'
41   else
42     fatal_ "error analyzing TAP::Parser module for bugs"
43   fi
44 fi
45
46 . tap-setup.sh
47
48 cat > a.test <<END
49 1..1
50 ok 0
51 END
52
53 cat > b.test <<END
54 1..1
55 not ok 0
56 END
57
58 cat > c.test <<END
59 1..1
60 ok 0 foo # SKIP
61 END
62
63 cat > d.test <<END
64 1..1
65 not ok 0 bar # TODO
66 END
67
68 cat > e.test <<END
69 1..1
70 ok 0 # TODO
71 END
72
73 run_make -O -e FAIL TESTS='a.test b.test c.test d.test e.test' check
74 count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=5
75
76 grep '^ERROR: a\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
77 grep '^ERROR: b\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
78 grep '^ERROR: c\.test 0 foo # OUT-OF-ORDER (expecting 1)$' stdout
79 grep '^ERROR: d\.test 0 bar # OUT-OF-ORDER (expecting 1)$' stdout
80 grep '^ERROR: e\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
81
82 :