Merge branch 'testsuite-saner-shell' into maint
[platform/upstream/automake.git] / t / self-check-dir.tap
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 that tests using './defs' create a proper temporary directory,
19 # and run in it.  Also check that we can prevent the pre-population
20 # and the creation of such directory if we want.
21
22 am_create_testdir=no
23 . ./defs || Exit 99
24
25 plan_ 5
26
27 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
28 keep_testdirs=; unset keep_testdirs
29
30 # This needs to be consistent with what $AM_TEST_RUNNER_SHELL
31 # deems to be the current working directory.
32 cwd=`$AM_TEST_RUNNER_SHELL -c 'pwd'` \
33   || fatal_ "can't get current working directory"
34 echo "$cwd"
35
36 do_check ()
37 {
38   test ! -d _self.dir || rm -rf _self.dir \
39     || framework_failure_ "cleaning up _self.dir"
40   command_ok_ "$1 [$2]" $AM_TEST_RUNNER_SHELL -c "
41     $2
42     . ./defs || Exit 99
43     # Don't fail if 'ls -l' fails; avoids possible racy spurious failures.
44     pwd; ls -l || : # For debugging.
45     $3
46   " t/_self.sh
47 }
48
49 do_check 'testdir has the expected path' \
50          'unset am_create_testdir' \
51          'case `pwd` in '"$cwd"'/t/_self.dir);; *) Exit 1;; esac'
52
53 do_check 'fully pre-populated testdir' \
54          'unset am_create_testdir' \
55          'test -f install-sh || Exit 1
56           test -f configure.ac || Exit 1
57           case `pwd` in '"$cwd"'/t/_self.dir) : ;; *) Exit 1;; esac'
58
59 do_check 'testdir has the expected path' \
60          'am_create_testdir=empty' \
61          'case `pwd` in '"$cwd"'/t/_self.dir) : ;; *) Exit 1;; esac'
62
63 do_check 'do not pre-populate testdir' \
64          'am_create_testdir=empty' \
65          'ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1; :'
66
67 do_check 'do not create nor chdir in testdir' \
68          'am_create_testdir=no' \
69          'test ! -d t/_self.dir || Exit 1
70           test ! -f t/_self.dir || Exit 1
71           test ! -r t/_self.dir || Exit 1
72           grep "self-check-dir\.tap" Makefile || Exit 1
73           case `pwd` in '"$cwd"') : ;; *) Exit 1;; esac'
74
75 :