tests: use more POSIX shell features our test scripts
[platform/upstream/automake.git] / t / self-check-explicit-skips.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 # Sanity check for the automake testsuite.
18 # Check creation/removal of temporary test working directory by './defs'.
19
20 am_create_testdir=empty
21 . ./defs || Exit 1
22
23 # We still need a little hack to make ./defs work outside automake's
24 # tree 'tests' subdirectory.  Not a big deal.
25 sed "s|^am_top_builddir=.*|am_top_builddir='$(pwd)'|" \
26   "$am_top_builddir"/defs-static > defs-static
27 diff "$am_top_builddir"/defs-static defs-static \
28   && fatal_ "failed to edit defs-static"
29 cp "$am_top_builddir"/defs .
30
31 set +e
32
33 unset am_explicit_skips stderr_fileno_
34 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
35
36 # I'm a lazy typist.
37 sh=$AM_TEST_RUNNER_SHELL
38
39 $sh -c '. ./defs; (exit 77); exit 77' dummy.test
40 test $? -eq 77 || Exit 1
41
42 am_explicit_skips=no $sh -c '. ./defs; sh -c "exit 77"' dummy.test
43 test $? -eq 77 || Exit 1
44
45 am_explicit_skips=yes $sh -c '. ./defs; (exit 77); exit 77' dummy.test
46 test $? -eq 78 || Exit 1
47
48 am_explicit_skips=y $sh -c '. ./defs; sh -c "exit 77"' dummy.test
49 test $? -eq 78 || Exit 1
50
51 am_explicit_skips=yes $sh -c '. ./defs; Exit 77' dummy.test
52 test $? -eq 77 || Exit 1
53
54 am_explicit_skips=y $sh -c '. ./defs; skip_ "foo"' dummy.test
55 test $? -eq 77 || Exit 1
56
57 :