maint: Update HACKING
[automake.git] / t / local.mk
blobb6bb6b662755c05b8c6c88f0f333f05e0b3877ec
1 ## -*- makefile-automake -*-
2 ## Copyright (C) 1995-2017 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.
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 ## ------------ ##
18 ## Testsuite. ##
19 ## ------------ ##
21 # Run the tests with a proper shell detected at configure time.
22 LOG_COMPILER = ./pre-inst-env $(AM_TEST_RUNNER_SHELL)
24 TEST_EXTENSIONS = .pl .sh .tap
25 SH_LOG_COMPILER = $(LOG_COMPILER)
26 TAP_LOG_COMPILER = $(LOG_COMPILER)
27 PL_LOG_COMPILER = ./pre-inst-env $(PERL)
28 AM_PL_LOG_FLAGS = -Mstrict -w
30 TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(srcdir)/lib/tap-driver.sh
32 AM_TAP_LOG_DRIVER_FLAGS = --merge
34 EXTRA_DIST += %D%/README %D%/ax/is %D%/ax/is_newest %D%/ax/deltree.pl
37 ## Will be updated later.
38 TESTS =
40 # Some testsuite-influential variables should be overridable from the
41 # test scripts, but not from the environment.
42 # Keep this in sync with the similar list in ax/runtest.in.
43 AM_TESTS_ENVIRONMENT = \
44 for v in \
45 required \
46 am_test_protocol \
47 am_serial_tests \
48 am_test_prefer_config_shell \
49 am_original_AUTOMAKE \
50 am_original_ACLOCAL \
51 am_test_lib_sourced \
52 test_lib_sourced \
53 ; do \
54 eval test x"\$${$$v}" = x || unset $$v; \
55 done;
56 # We want warning messages and explanations for skipped tests to go to
57 # the console if possible, so set up 'stderr_fileno_' properly.
58 AM_TESTS_FD_REDIRECT = 9>&2
59 AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
61 # For sourcing of extra "shell libraries" by our test scripts. As per
62 # POSIX, sourcing a file with '.' will cause it to be looked up in $PATH
63 # in case it is given with a relative name containing no slashes.
64 AM_TESTS_ENVIRONMENT += \
65 if test $(srcdir) != .; then \
66 PATH='$(abs_srcdir)/%D%/ax$(PATH_SEPARATOR)'$$PATH; \
67 fi; \
68 PATH='$(abs_builddir)/%D%/ax$(PATH_SEPARATOR)'$$PATH; \
69 export PATH;
71 # Hand-written tests.
73 include $(srcdir)/%D%/list-of-tests.mk
75 TESTS += $(handwritten_TESTS)
76 EXTRA_DIST += $(handwritten_TESTS)
78 # Automatically-generated tests wrapping hand-written ones.
79 # Also, automatically-computed dependencies for tests.
81 include $(srcdir)/%D%/testsuite-part.am
83 TESTS += $(generated_TESTS)
84 EXTRA_DIST += $(generated_TESTS)
86 $(srcdir)/%D%/testsuite-part.am:
87 $(AM_V_at)rm -f %D%/testsuite-part.tmp $@
88 $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
89 --srcdir $(srcdir) > %D%/testsuite-part.tmp
90 $(AM_V_at)chmod a-w %D%/testsuite-part.tmp
91 $(AM_V_at)mv -f %D%/testsuite-part.tmp $@
92 EXTRA_DIST += gen-testsuite-part
94 # The dependecies declared here are not truly complete, but such
95 # completeness would cause more issues than it would solve. See
96 # automake bug#11347.
97 $(generated_TESTS): $(srcdir)/gen-testsuite-part
98 $(srcdir)/%D%/testsuite-part.am: $(srcdir)/gen-testsuite-part
99 $(srcdir)/%D%/testsuite-part.am: Makefile.am
101 # Hand-written tests for stuff in 'contrib/'.
102 include $(srcdir)/contrib/%D%/local.mk
103 TESTS += $(contrib_TESTS)
104 EXTRA_DIST += $(contrib_TESTS)
106 # Static dependencies valid for each test case (also further
107 # extended later). Note that use 'noinst_' rather than 'check_'
108 # as the prefix, because we really want them to be built by
109 # "make all". This makes it easier to run the test cases by
110 # hand after having simply configured and built the package.
112 dist_noinst_DATA += \
113 %D%/ax/test-init.sh \
114 %D%/ax/test-lib.sh \
115 %D%/ax/am-test-lib.sh \
116 %D%/ax/tap-functions.sh
118 # Few more static dependencies.
119 %D%/distcheck-missing-m4.log: %D%/ax/distcheck-hook-m4.am
120 %D%/distcheck-outdated-m4.log: %D%/ax/distcheck-hook-m4.am
121 EXTRA_DIST += %D%/ax/distcheck-hook-m4.am
123 %D%/ax/test-defs.sh: %D%/ax/test-defs.in Makefile
124 $(AM_V_at)rm -f $@ $@-t
125 $(AM_V_at)$(MKDIR_P) %D%/ax
126 $(AM_V_GEN)in=%D%/ax/test-defs.in \
127 && $(do_subst) <$(srcdir)/$$in >$@-t
128 $(generated_file_finalize)
129 EXTRA_DIST += %D%/ax/test-defs.in
130 CLEANFILES += %D%/ax/test-defs.sh
131 nodist_noinst_DATA += %D%/ax/test-defs.sh
133 %D%/ax/shell-no-trail-bslash: %D%/ax/shell-no-trail-bslash.in Makefile
134 $(AM_V_at)rm -f $@ $@-t
135 $(AM_V_GEN)in=%D%/ax/shell-no-trail-bslash.in \
136 && $(MKDIR_P) %D%/ax \
137 && $(do_subst) <$(srcdir)/$$in >$@-t \
138 && chmod a+x $@-t
139 $(generated_file_finalize)
140 EXTRA_DIST += %D%/ax/shell-no-trail-bslash.in
141 CLEANFILES += %D%/ax/shell-no-trail-bslash
142 nodist_noinst_SCRIPTS += %D%/ax/shell-no-trail-bslash
144 %D%/ax/cc-no-c-o: %D%/ax/cc-no-c-o.in Makefile
145 $(AM_V_at)rm -f $@ $@-t
146 $(AM_V_GEN)in=%D%/ax/cc-no-c-o.in \
147 && $(MKDIR_P) %D%/ax \
148 && $(do_subst) <$(srcdir)/$$in >$@-t \
149 && chmod a+x $@-t
150 $(generated_file_finalize)
151 EXTRA_DIST += %D%/ax/cc-no-c-o.in
152 CLEANFILES += %D%/ax/cc-no-c-o
153 nodist_noinst_SCRIPTS += %D%/ax/cc-no-c-o
155 runtest: %D%/ax/runtest.in Makefile
156 $(AM_V_at)rm -f $@ $@-t
157 $(AM_V_GEN)in=%D%/ax/runtest.in \
158 && $(MKDIR_P) %D%/ax \
159 && $(do_subst) <$(srcdir)/$$in >$@-t \
160 && chmod a+x $@-t
161 $(generated_file_finalize)
162 EXTRA_DIST += %D%/ax/runtest.in
163 CLEANFILES += runtest
164 nodist_noinst_SCRIPTS += runtest
166 # If two test scripts have the same basename, they will end up sharing
167 # the same log file, leading to all sort of undefined and undesired
168 # behaviours.
169 check-no-repeated-test-name:
170 @LC_ALL=C; export LC_ALL; \
171 lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \
172 | sort | uniq -c | awk '($$1 > 1) { print }' \
173 | sed 's/\.log$$//' | grep . >&2 \
174 && { \
175 echo $@: test names listed above are duplicated >&2; \
176 exit 1; \
177 }; :
178 check-local: check-no-repeated-test-name
179 .PHONY: check-no-repeated-test-name
181 # Check that our test cases are syntactically correct.
182 # See automake bug#11898.
183 check-tests-syntax:
184 @st=0; \
185 err () { echo "$@: $$*" >&2; st=1; }; \
186 ## The user might do something like "make check TESTS=t/foo" or
187 ## "make check TESTS_LOGS=t/foo.log" and expect (say) the test
188 ## 't/foo.sh' to be run; this has worked well until today, and
189 ## we want to continue supporting this use case.
190 bases=`for log in : $(TEST_LOGS); do echo $$log; done \
191 | sed -e '/^:$$/d' -e 's/\.log$$//'`; \
192 for bas in $$bases; do \
193 for suf in sh tap pl; do \
194 tst=$$bas.$$suf; \
195 ## Emulate VPATH search.
196 if test -f $$tst; then \
197 break; \
198 elif test -f $(srcdir)/$$tst; then \
199 tst=$(srcdir)/$$tst; \
200 break; \
201 else \
202 tst=''; \
203 fi; \
204 done; \
205 test -n "$$tst" || err "couldn't find test '$$bas'"; \
206 ## Don't check that perl tests are valid shell scripts!
207 test $$suf = pl && continue; \
208 $(AM_V_P) && echo " $(AM_TEST_RUNNER_SHELL) -n $$tst"; \
209 $(AM_TEST_RUNNER_SHELL) -n "$$tst" \
210 || err "test '$$tst' syntactically invalid"; \
211 done; \
212 exit $$st
213 check-local: check-tests-syntax
214 .PHONY: check-tests-syntax
216 # Recipes with a trailing backslash character (possibly followed by
217 # blank characters only) can cause spurious syntax errors with at
218 # least older bash versions (e.g., bash 2.05b), and can be potentially
219 # be unportable to other weaker shells. Run the testsuite in a way
220 # that helps catching such problems in Automake-generated recipes.
221 # See automake bug#10436.
222 check-no-trailing-backslash-in-recipes:
223 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
224 CONFIG_SHELL='$(abs_top_builddir)/%D%/ax/shell-no-trail-bslash'
225 .PHONY: check-no-trailing-backslash-in-recipes
227 # Some compilers out there (hello, MSVC) still choke on "-c -o" being
228 # passed together on the command line. Run the whole testsuite faking
229 # the presence of such a compiler, to help catch regressions that would
230 # otherwise only present themselves later "in the wild". See also the
231 # long discussion about automake bug#13378.
232 check-cc-no-c-o:
233 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
234 AM_TESTSUITE_SIMULATING_NO_CC_C_O=yes
235 .PHONY: check-cc-no-c-o
237 # Automake-generated Makefiles should work when run with parallel make.
238 check-parallel:
239 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
240 AM_TESTSUITE_MAKE="$${AM_TESTSUITE_MAKE-$${MAKE-make}} -j4"
241 .PHONY: check-parallel
243 ## Checking the list of tests.
244 test_subdirs = %D% %D%/pm contrib/%D%
245 include %D%/CheckListOfTests.am
247 # Run the testsuite with the installed aclocal and automake.
248 installcheck-local: installcheck-testsuite
249 installcheck-testsuite:
250 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
251 am_running_installcheck=yes
253 # Performance tests.
254 .PHONY: perf
255 perf: all
256 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
257 TEST_SUITE_LOG='$(PERF_TEST_SUITE_LOG)' TESTS='$(perf_TESTS)'
258 PERF_TEST_SUITE_LOG = %D%/perf/test-suite.log
259 CLEANFILES += $(PERF_TEST_SUITE_LOG)
260 EXTRA_DIST += $(perf_TESTS)
262 clean-local: clean-local-check
263 .PHONY: clean-local-check
264 clean-local-check:
265 $(AM_V_GEN)$(PERL) $(srcdir)/t/ax/deltree.pl t/*.dir t/*/*.dir */t/*.dir
267 # vim: ft=automake noet