tests: rename $am_make_rc_got -> $am_make_rc
[platform/upstream/automake.git] / t / self-check-seq.tap
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 # Sanity check for the automake testsuite.
18 # Check the 'seq_' subroutine.
19
20 . test-init.sh
21
22 plan_ 14
23
24 unset stderr_fileno_
25
26 check_work ()
27 {
28   desc=$1 args=$2 exp=$3
29   st=0; got=$(seq_ $args) || st=$?
30   command_ok_ "$desc [exit status = 0]" test $st -eq 0
31   command_ok_ "$desc [output]" test x"$exp" = x"$got"
32 }
33
34 check_work 'one-argument form' '5' "\
35 1
36 2
37 3
38 4
39 5"
40
41 check_work 'two-arguments form' '7 11' "\
42 7
43 8
44 9
45 10
46 11"
47
48 check_work 'three-arguments form (1)' '120 5 135' "\
49 120
50 125
51 130
52 135"
53
54 check_work 'three-arguments form (1)' '13 4 23' "\
55 13
56 17
57 21"
58
59 check_err ()
60 {
61   desc=$1 args=$2 err=$3
62   (seq_ $args) >output || st=$?
63   # Protect content emitted on stdout/stderr, to avoid sending to the
64   # TAP driver possible "Bail out!" directives generated by 'seq_'.
65   # Use 'grep -c' below for the same reason.
66   sed 's/^/: /' output
67   command_ok_ "$desc [exit status = 99]" test $st -eq 99
68   command_ok_ "$desc [error message]" grep -c "seq_: $err" output
69 }
70
71 check_err 'no argument is an error' '' 'missing argument'
72 check_err 'four arguments is an error' '1 1 2 1' 'too many arguments'
73 check_err 'six arguments is an error' '1 1 1 1 1 1' 'too many arguments'
74
75 :