maint: Update HACKING
[automake.git] / t / am-missing-prog.sh
blob59a61b24d49de9c16c446b461596a8e30f50df4c
1 #! /bin/sh
2 # Copyright (C) 2003-2017 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test AM_MISSING_PROG.
19 . test-init.sh
21 cat >> configure.ac <<'END'
22 AM_MISSING_PROG([NO_SUCH_COMMAND], [am-none-none])
23 AM_MISSING_PROG([MISMATCHED_COMMAND], [am-exit-63])
24 AM_MISSING_PROG([OVERRIDDEN_COMMAND], [am-none-none])
25 AM_MISSING_PROG([COMMAND_FOUND], [my-command])
26 AC_OUTPUT
27 END
29 mkdir bin
30 cat > bin/am-exit-63 <<'END'
31 #!/bin/sh
32 echo "Oops, I'm too old"
33 exit 63
34 END
35 cat > bin/am-overridden <<'END'
36 #!/bin/sh
37 echo "Hey, I'm OK!"
38 exit 0
39 END
40 cat > bin/my-command <<'END'
41 #!/bin/sh
42 echo SNAFU
43 exit 0
44 END
45 chmod a+x bin/*
46 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
48 cat > Makefile.am <<'END'
49 # Different for different targets, for the sake of parallel make.
50 o = $@-stdout
51 e = $@-stderr
53 debug_info = grep . $@-stdout $@-stderr
54 status_is = $(debug_info); echo $@: st=$$st; test $$st -eq
56 w_mis = 'am-none-none' is needed, and is missing on your system
57 w_old = 'am-exit-63' is needed, and is probably too old
59 test1:
60 st=0; $(NO_SUCH_COMMAND) >$o 2>$e || st=$$?; $(status_is) 127
61 grep "^WARNING: $(w_mis)" $e
62 test ! -s $o
63 test2:
64 st=0; $(MISMATCHED_COMMAND) >$o 2>$e || st=$$?; $(status_is) 63
65 grep "^WARNING: $(w_old)" $e
66 test "`cat $o`" = "Oops, I'm too old"
67 test3:
68 st=0; $(OVERRIDDEN_COMMAND) >$o 2>$e || st=$$?; $(status_is) 0
69 st=0; $(OVERRIDDEN_COMMAND) >$o 2>$e || st=$$?; \
70 test ! -s $e
71 test "`cat $o`" = "Hey, I'm OK!"
72 test4:
73 st=0; $(COMMAND_FOUND) >$o 2>$e || st=$$?; $(status_is) 0
74 test ! -s $e
75 test "`cat $o`" = SNAFU
76 check-local: test1 test2 test2 test4
77 .PHONY: test1 test2 test2 test4
78 CLEANFILES = test[1234]-stdout test[1234]-stderr
79 END
81 $ACLOCAL
82 $AUTOCONF
83 $AUTOMAKE
85 ./configure OVERRIDDEN_COMMAND=am-overridden
87 $FGREP COMMAND Makefile.in Makefile # For debugging.
89 grep "^NO_SUCH_COMMAND = \${SHELL} .*/missing .*am-none-none" Makefile
90 grep "^MISMATCHED_COMMAND = \${SHELL} .*/missing .*am-exit-63" Makefile
91 grep "^COMMAND_FOUND = \${SHELL} .*/missing .*my-command" Makefile
92 grep '^OVERRIDDEN_COMMAND = am-overridden *$' Makefile
94 $MAKE test1 test2 test3 test4
95 $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS='OVERRIDDEN_COMMAND=am-overridden'