5696b44d6ff321a3910a8328446bf35a3d882d39
[platform/upstream/automake.git] / tests / Makefile.am
1 ## Process this file with automake to create Makefile.in
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
4 # 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
5 # Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 # Run the tests with the shell detected at configure time.
21 LOG_COMPILER = $(SHELL)
22
23 TEST_EXTENSIONS = .pl .test .tap
24 TEST_LOG_COMPILER = $(LOG_COMPILER)
25 TAP_LOG_COMPILER = $(LOG_COMPILER)
26 PL_LOG_COMPILER = $(PERL)
27 AM_PL_LOG_FLAGS = -Mstrict -I $(top_builddir)/lib -I $(top_srcdir)/lib -w
28
29 TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/lib/tap-driver.sh
30
31 AM_TAP_LOG_DRIVER_FLAGS = --merge --comments
32 ## Avoid spurious TAP diagnostic.  We use an awful indirection with a
33 ## shell command substitution here, since the string needs to contain
34 ## `#' characters, and these can't be escaped portably in a make macro
35 ## definition.
36 ## FIXME: this is quite inefficient though, as it adds one extra fork
37 ## FIXME: per TAP test script; this is OK for the moment, since we have
38 ## FIXME: few such scripts, but might become an issue in the future.
39 ## Keep this in sync with the definition of $diag_string_ in tests/defs.
40 AM_TAP_LOG_DRIVER_FLAGS += --diagnostic-string `printf '\043%%\043\n'`
41
42 EXTRA_DIST = ChangeLog-old
43
44 TESTS = ## Will be updated later.
45
46 XFAIL_TESTS = \
47 all.test \
48 cond17.test \
49 gcj6.test \
50 override-conditional-2.test \
51 java-nobase.test \
52 objext-pr10128.test \
53 pr8365-remake-timing.test \
54 lex-subobj-nodep.test \
55 remake-am-pr10111.test \
56 remake-m4-pr10111.test \
57 txinfo5.test \
58 ## FIXME: this "expected failures" are in truth an hack used to
59 ## FIXME: to verify that some incorrect usages of our perl: libraries
60 ## FIXME: raise an error.  We should find a cleaner way to check that.
61 pm/Cond2.pl \
62 pm/Cond3.pl \
63 pm/DisjCon2.pl \
64 pm/DisjCon3.pl \
65 pm/Version2.pl \
66 pm/Version3.pl
67
68 # Some testsuite-influential variables should be overridable from the
69 # test scripts, but not from the environment.
70 AM_TESTS_ENVIRONMENT = \
71   for v in \
72     me \
73     required \
74     am_using_tap \
75     am_parallel_tests \
76     am_test_prefer_config_shell \
77     am_original_AUTOMAKE \
78     am_original_ACLOCAL \
79   ; do \
80     eval test x"\$${$$v}" = x || unset $$v; \
81   done;
82 # The `AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
83 # re-execute themselves with the shell detected at configure time, since
84 # we are already running them under it explicitly in our setup (see e.g.
85 # the definition of TEST_LOG_COMPILER above).
86 AM_TESTS_ENVIRONMENT += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
87 # We want warning messages and explanations for skipped tests to go to
88 # the console if possible, so set up `stderr_fileno_' properly.
89 AM_TESTS_FD_REDIRECT = 9>&2
90 AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
91
92 # Hand-written tests.
93
94 include $(srcdir)/list-of-tests.mk
95
96 TESTS += $(handwritten_TESTS)
97 EXTRA_DIST += $(handwritten_TESTS)
98
99 # Automatically-generated tests wrapping hand-written ones.
100 # Also, automatically-computed dependencies for tests.
101
102 include $(srcdir)/testsuite-part.am
103
104 TESTS += $(generated_TESTS)
105 EXTRA_DIST += $(generated_TESTS)
106
107 $(srcdir)/testsuite-part.am:
108         $(AM_V_at)rm -f testsuite-part.tmp $@
109         $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
110           --srcdir $(srcdir) > testsuite-part.tmp
111         $(AM_V_at)chmod a-w testsuite-part.tmp
112         $(AM_V_at)mv -f testsuite-part.tmp $@
113 EXTRA_DIST += gen-testsuite-part
114
115 $(generated_TESTS) $(srcdir)/testsuite-part.am: \
116   gen-testsuite-part list-of-tests.mk Makefile.am $(handwritten_TESTS)
117
118 # Static dependencies valid for each test case.
119 check_SCRIPTS = aclocal-$(APIVERSION) automake-$(APIVERSION)
120 check_DATA = defs defs-static plain-functions.sh tap-functions.sh
121 EXTRA_DIST += tap-functions.sh plain-functions.sh
122
123 # Few more static dependencies.
124 distcheck-missing-m4.log distcheck-outdated-m4.log: distcheck-hook-m4.am
125 EXTRA_DIST += distcheck-hook-m4.am
126
127 # Keep in sync with AC_SUBST'd stuff in defs-static.in.
128 do_subst = sed \
129   -e 's|@abs_srcdir[@]|$(abs_srcdir)|g' \
130   -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
131   -e 's|@abs_builddir[@]|$(abs_builddir)|g' \
132   -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
133   -e 's|@prefix[@]|$(prefix)|g' \
134   -e 's|@amdir[@]|$(amdir)|g' \
135   -e 's|@bindir[@]|$(bindir)|g' \
136   -e 's|@datadir[@]|$(datadir)|g' \
137   -e 's|@docdir[@]|$(docdir)|g' \
138   -e 's|@automake_acdir[@]|$(automake_acdir)|g' \
139   -e 's|@system_acdir[@]|$(system_acdir)|g' \
140   -e 's|@scriptdir[@]|$(scriptdir)|g' \
141   -e 's|@pkgvdatadir[@]|$(pkgvdatadir)|g' \
142   -e 's|@host_alias[@]|$(host_alias)|g' \
143   -e 's|@build_alias[@]|$(build_alias)|g' \
144   -e 's|@APIVERSION[@]|$(APIVERSION)|g' \
145   -e 's|@PATH_SEPARATOR[@]|$(PATH_SEPARATOR)|g' \
146   -e 's|@SHELL[@]|$(SHELL)|g' \
147   -e 's|@PERL[@]|$(PERL)|g' \
148   -e 's|@EGREP[@]|$(EGREP)|g' \
149   -e 's|@FGREP[@]|$(FGREP)|g' \
150   -e 's|@TEX[@]|$(TEX)|g' \
151   -e 's|@MODIFICATION_DELAY[@]|$(MODIFICATION_DELAY)|g' \
152   -e 's|@am_AUTOCONF[@]|$(am_AUTOCONF)|g' \
153   -e 's|@am_AUTOM4TE[@]|$(am_AUTOM4TE)|g' \
154   -e 's|@am_AUTORECONF[@]|$(am_AUTORECONF)|g' \
155   -e 's|@am_AUTOHEADER[@]|$(am_AUTOHEADER)|g' \
156   -e 's|@am_AUTOUPDATE[@]|$(am_AUTOUPDATE)|g' \
157   -e 's|@sh_errexit_works[@]|$(sh_errexit_works)|g' \
158   -e 's|@configure_input[@]|Generated from $@.in.  DO NOT EDIT BY HAND!|'
159
160 defs-static: defs-static.in
161         $(AM_V_at)rm -f $@ $@-t
162         $(AM_V_GEN)$(do_subst) $(srcdir)/defs-static.in >$@-t
163         $(AM_V_at) : Sanity check on the substitutions; \
164         if LC_ALL=C grep '@[a-zA-Z0-9_][a-zA-Z0-9_]*@' $@-t; then \
165           echo "$@ contains unexpanded substitution (see lines above)"; \
166           exit 1; \
167         fi
168         $(AM_V_at)chmod a-w $@-t && mv -f $@-t $@
169 EXTRA_DIST += defs-static.in
170 CLEANFILES = defs-static
171
172 # If two test scripts have the same basename, they will end up sharing
173 # the same log file, leading to all sort of undefined and undesired
174 # behaviours.
175 check-no-repeated-test-name:
176         @LC_ALL=C; export LC_ALL; \
177          lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \
178            | sort | uniq -c | awk '($$1 > 1) { print }' \
179            | sed 's/\.log$$//' | grep . >&2 \
180            && { \
181              echo $@: test names listed above are duplicated >&2; \
182              exit 1; \
183            }; :
184 check-local: check-no-repeated-test-name
185 .PHONY: check-no-repeated-test-name
186
187 ## Checking the list of tests.
188 test_subdirs = . pm
189 include $(srcdir)/CheckListOfTests.am
190
191 # Run the testsuite with the installed aclocal and automake.
192 installcheck-local:
193         am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
194
195 clean-local: clean-local-check
196 .PHONY: clean-local-check
197 clean-local-check:
198         -set x *.dir; shift; \
199          if test "$$#,$$1" = "1,*.dir"; then \
200            : there is no test directory to clean; \
201          else \
202            find "$$@" -type d ! -perm -700 -exec chmod u+rwx {} ';'; \
203            rm -rf "$$@"; \
204          fi;
205
206 ## Run the testsuite through the `prove' utility.  Mostly for maintainers,
207 ## and to find out possible incompatibilities between `prove' and the
208 ## Automake own TAP driver.
209
210 PROVE = prove
211 AM_PROVEFLAGS = --timer
212 AM_PROVECMD = \
213   test -z "$$tests" || \
214     { \
215       $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) \
216       $(PROVE) $(AM_PROVEFLAGS) -e $(srcdir)/prove-runner $(PROVEFLAGS) \
217       $$tests $(AM_TESTS_FD_REDIRECT); \
218     }
219
220 EXTRA_DIST += prove-runner
221
222 .PHONY: prove installprove
223 prove installprove: $(TESTS) prove-runner defs-static
224         @exit_status=0; \
225 ## The testsuite can be run either using the automake build tree or
226 ## the already-installed automake package.
227         case '$@' in \
228           install*) am_running_installcheck=yes;; \
229           *) am_running_installcheck=no;; \
230         esac; \
231         export am_running_installcheck; \
232 ## XXX Our poor-man way to handle inter-tests dependencies without the
233 ## XXX help of make.  This is obviously fragile and doesn't scale,
234 ## XXX but for now it's good enough since we have only one possible
235 ## XXX inter-tests dependency at the moment.
236         need_tap_common_setup=no; \
237         lst=' $(TESTS) '; for t in $$lst; do \
238           case ' $(on_tap_with_common_setup_TESTS) ' in \
239             *" $$t "*) need_tap_common_setup=yes; break;; \
240           esac; \
241         done; \
242 ## For VPATH builds.
243         if test $$need_tap_common_setup = yes; then \
244           t=tap-common-setup.test; \
245           if test -f ./$$t; then \
246             tests=./$$t; \
247           else \
248             tests=$(srcdir)/$$t; \
249           fi; \
250 ## Do not stop if there's a failure here, we want to run the following
251 ## tests anyway.
252           echo "$@: running pre-requisite tests ..."; \
253           $(AM_PROVECMD) || exits_status=$$?; \
254           echo "$@: done.  We'll shortly run the main testsuite."; \
255         fi; \
256 ## Handle VPATH builds, and ensure that the tests have a properly
257 ## qualified path.
258         tests=`\
259           for t in $(TESTS); do \
260 ## XXX In next line, another hack for inter-tests dependencies: this
261 ## XXX can't run concurrently to the tests that use the data files it
262 ## XXX generates.
263             case "$$need_tap_common_setup,/$$t" in \
264               yes,*/tap-common-setup.test) continue;; \
265             esac; \
266             if test -f ./$$t; then \
267               echo ./$$t; \
268             else \
269               echo $(srcdir)/$$t; \
270             fi; \
271           done`; \
272 ## Extra environment, mostly for use by `prove-runner'.
273 ## XFAIL_TESTS gets normalized to play nicer with VPATH builds.
274         XFAIL_TESTS=`\
275           for t in $(XFAIL_TESTS); do \
276             echo $$t; echo ./$$t; echo $(srcdir)/$$t; \
277           done | LC_ALL=C sort | uniq`; \
278         XFAIL_TESTS=`echo $$XFAIL_TESTS`; \
279         TAP_RUNNER='$(TAP_LOG_COMPILE)' \
280         TEST_RUNER='$(TEST_LOG_COMPILE)' \
281         export XFAIL_TESTS TAP_RUNNER TEST_RUNNER; \
282 ## For consistency with the Automake testsuite harness, that exports
283 ## this unconditionally in the test scripts' environment.
284         srcdir='$(srcdir)'; export srcdir; \
285 ## Here we go.
286         $(AM_PROVECMD) || exit_status=$$?; \
287         exit $$exit_status;