maint: it seems APIVERSION only changes for minor/major releases.
[automake.git] / t / local.mk
blobb1a8eb7eab80f466d755d3014f740a64f3403f7a
1 ## -*- makefile-automake -*-
2 ## Copyright (C) 1995-2024 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 ACLOCAL \
46 AUTOCONF \
47 AUTOHEADER \
48 AUTOMAKE \
49 AUTOUPDATE \
50 required \
51 am_test_protocol \
52 am_serial_tests \
53 am_test_prefer_config_shell \
54 am_original_AUTOMAKE \
55 am_original_ACLOCAL \
56 am_test_lib_sourced \
57 test_lib_sourced \
58 ; do \
59 eval test x\"\$${$$v}\" = x || unset $$v; \
60 done;
61 # We want warning messages and explanations for skipped tests to go to
62 # the console if possible, so set up 'stderr_fileno_' properly.
63 AM_TESTS_FD_REDIRECT = 9>&2
64 AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
66 # For sourcing of extra "shell libraries" by our test scripts. As per
67 # POSIX, sourcing a file with '.' will cause it to be looked up in $PATH
68 # in case it is given with a relative name containing no slashes.
69 AM_TESTS_ENVIRONMENT += \
70 if test $(srcdir) != .; then \
71 PATH='$(abs_srcdir)/%D%/ax$(PATH_SEPARATOR)'$$PATH; \
72 fi; \
73 PATH='$(abs_builddir)/%D%/ax$(PATH_SEPARATOR)'$$PATH; \
74 export PATH;
76 # Hand-written tests.
78 include $(srcdir)/%D%/list-of-tests.mk
80 TESTS += $(handwritten_TESTS)
81 EXTRA_DIST += $(handwritten_TESTS)
83 # Automatically-generated tests wrapping hand-written ones.
84 # Also, automatically-computed dependencies for tests.
86 include $(srcdir)/%D%/testsuite-part.am
88 TESTS += $(generated_TESTS)
89 EXTRA_DIST += $(generated_TESTS)
91 $(srcdir)/%D%/testsuite-part.am:
92 $(AM_V_at)rm -f %D%/testsuite-part.tmp $@
93 $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
94 --srcdir $(srcdir) > %D%/testsuite-part.tmp
95 $(AM_V_at)chmod a-w %D%/testsuite-part.tmp
96 $(AM_V_at)mv -f %D%/testsuite-part.tmp $@
97 EXTRA_DIST += gen-testsuite-part
99 # The dependencies declared here are not truly complete, but such
100 # completeness would cause more issues than it would solve. See
101 # automake bug#11347 and #44458.
102 $(generated_TESTS): $(srcdir)/gen-testsuite-part
103 $(srcdir)/%D%/testsuite-part.am: $(srcdir)/gen-testsuite-part
104 $(srcdir)/%D%/testsuite-part.am: Makefile.am
105 $(srcdir)/%D%/testsuite-part.am: %D%/list-of-tests.mk
107 # Hand-written tests for stuff in 'contrib/'.
108 include $(srcdir)/contrib/%D%/local.mk
109 TESTS += $(contrib_TESTS)
110 EXTRA_DIST += $(contrib_TESTS)
112 # Static dependencies valid for each test case (also further
113 # extended later). Note that use 'noinst_' rather than 'check_'
114 # as the prefix, because we really want them to be built by
115 # "make all". This makes it easier to run the test cases by
116 # hand after having simply configured and built the package.
118 dist_noinst_DATA += \
119 %D%/ax/test-init.sh \
120 %D%/ax/test-lib.sh \
121 %D%/ax/am-test-lib.sh \
122 %D%/ax/tap-functions.sh
124 # Few more static dependencies.
125 %D%/distcheck-missing-m4.log: %D%/ax/distcheck-hook-m4.am
126 %D%/distcheck-outdated-m4.log: %D%/ax/distcheck-hook-m4.am
127 EXTRA_DIST += %D%/ax/distcheck-hook-m4.am
129 %D%/ax/test-defs.sh: %D%/ax/test-defs.in Makefile
130 $(AM_V_at)rm -f $@ $@-t
131 $(AM_V_at)$(MKDIR_P) %D%/ax
132 $(AM_V_GEN)in=%D%/ax/test-defs.in \
133 && $(do_subst) <$(srcdir)/$$in >$@-t
134 $(generated_file_finalize)
135 EXTRA_DIST += %D%/ax/test-defs.in
136 CLEANFILES += %D%/ax/test-defs.sh
137 nodist_noinst_DATA += %D%/ax/test-defs.sh
139 %D%/ax/shell-no-trail-bslash: %D%/ax/shell-no-trail-bslash.in Makefile
140 $(AM_V_at)rm -f $@ $@-t
141 $(AM_V_GEN)in=%D%/ax/shell-no-trail-bslash.in \
142 && $(MKDIR_P) %D%/ax \
143 && $(do_subst) <$(srcdir)/$$in >$@-t \
144 && chmod a+x $@-t
145 $(generated_file_finalize)
146 EXTRA_DIST += %D%/ax/shell-no-trail-bslash.in
147 CLEANFILES += %D%/ax/shell-no-trail-bslash
148 nodist_noinst_SCRIPTS += %D%/ax/shell-no-trail-bslash
150 %D%/ax/cc-no-c-o: %D%/ax/cc-no-c-o.in Makefile
151 $(AM_V_at)rm -f $@ $@-t
152 $(AM_V_GEN)in=%D%/ax/cc-no-c-o.in \
153 && $(MKDIR_P) %D%/ax \
154 && $(do_subst) <$(srcdir)/$$in >$@-t \
155 && chmod a+x $@-t
156 $(generated_file_finalize)
157 EXTRA_DIST += %D%/ax/cc-no-c-o.in
158 CLEANFILES += %D%/ax/cc-no-c-o
159 nodist_noinst_SCRIPTS += %D%/ax/cc-no-c-o
161 runtest: %D%/ax/runtest.in Makefile
162 $(AM_V_at)rm -f $@ $@-t
163 $(AM_V_GEN)in=%D%/ax/runtest.in \
164 && $(MKDIR_P) %D%/ax \
165 && $(do_subst) <$(srcdir)/$$in >$@-t \
166 && chmod a+x $@-t
167 $(generated_file_finalize)
168 EXTRA_DIST += %D%/ax/runtest.in
169 CLEANFILES += runtest
170 nodist_noinst_SCRIPTS += runtest
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 # behaviors.
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
187 # Check that our test cases are syntactically correct.
188 # See automake bug#11898.
189 check-tests-syntax:
190 @st=0; \
191 err () { echo "$@: $$*" >&2; st=1; }; \
192 ## The user might do something like "make check TESTS=t/foo" or
193 ## "make check TESTS_LOGS=t/foo.log" and expect (say) the test
194 ## 't/foo.sh' to be run; this has worked well until today, and
195 ## we want to continue supporting this use case.
196 bases=`for log in : $(TEST_LOGS); do echo $$log; done \
197 | sed -e '/^:$$/d' -e 's/\.log$$//'`; \
198 for bas in $$bases; do \
199 for suf in sh tap pl; do \
200 tst=$$bas.$$suf; \
201 ## Emulate VPATH search.
202 if test -f $$tst; then \
203 break; \
204 elif test -f $(srcdir)/$$tst; then \
205 tst=$(srcdir)/$$tst; \
206 break; \
207 else \
208 tst=''; \
209 fi; \
210 done; \
211 test -n "$$tst" || err "couldn't find test '$$bas'"; \
212 ## Don't check that perl tests are valid shell scripts!
213 test $$suf = pl && continue; \
214 $(AM_V_P) && echo " $(AM_TEST_RUNNER_SHELL) -n $$tst"; \
215 $(AM_TEST_RUNNER_SHELL) -n "$$tst" \
216 || err "test '$$tst' syntactically invalid"; \
217 done; \
218 exit $$st
219 check-local: check-tests-syntax
220 .PHONY: check-tests-syntax
222 # Recipes with a trailing backslash character (possibly followed by
223 # blank characters only) can cause spurious syntax errors with at
224 # least older bash versions (e.g., bash 2.05b), and can be potentially
225 # be unportable to other weaker shells. Run the testsuite in a way
226 # that helps catching such problems in Automake-generated recipes.
227 # See automake bug#10436.
228 check-no-trailing-backslash-in-recipes:
229 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
230 CONFIG_SHELL='$(abs_top_builddir)/%D%/ax/shell-no-trail-bslash'
231 .PHONY: check-no-trailing-backslash-in-recipes
233 # Some compilers out there (hello, MSVC) still choke on "-c -o" being
234 # passed together on the command line. Run the whole testsuite faking
235 # the presence of such a compiler, to help catch regressions that would
236 # otherwise only present themselves later "in the wild". See also the
237 # long discussion about automake bug#13378.
238 check-cc-no-c-o:
239 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
240 AM_TESTSUITE_SIMULATING_NO_CC_C_O=yes
241 .PHONY: check-cc-no-c-o
243 # Automake-generated Makefiles should work when run with parallel make.
244 check-parallel:
245 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
246 AM_TESTSUITE_MAKE="$${AM_TESTSUITE_MAKE-$${MAKE-make}} -j4"
247 .PHONY: check-parallel
249 ## Checking the list of tests.
250 test_subdirs = %D% %D%/pm contrib/%D%
251 include %D%/CheckListOfTests.am
253 # Run the testsuite with the installed aclocal and automake without using
254 # the 'pre-inst-env' wrapper script.
255 installcheck-local: installcheck-testsuite
256 installcheck-testsuite:
257 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
258 LOG_COMPILER=$(AM_TEST_RUNNER_SHELL) \
259 PL_LOG_COMPILER=$(PERL) \
260 am_running_installcheck=yes
262 # Ensure that the installed Automake perl modules are found when running 'installcheck' target
263 AM_TESTS_ENVIRONMENT += \
264 if test "$${am_running_installcheck}" = yes; then \
265 PERL5LIB="$(DESTDIR)$(pkgvdatadir)/$${PERL5LIB:+$(PATH_SEPARATOR)}$$PERL5LIB"; \
266 fi; \
267 export PERL5LIB;
269 # Performance tests.
270 .PHONY: perf
271 perf: all
272 $(AM_V_GEN)$(MAKE) $(AM_MAKEFLAGS) check \
273 TEST_SUITE_LOG='$(PERF_TEST_SUITE_LOG)' TESTS='$(perf_TESTS)'
274 PERF_TEST_SUITE_LOG = %D%/perf/test-suite.log
275 CLEANFILES += $(PERF_TEST_SUITE_LOG)
276 EXTRA_DIST += $(perf_TESTS)
278 clean-local: clean-local-check
279 .PHONY: clean-local-check
280 clean-local-check:
281 find . -type d ! -perm -700 -exec chmod u+rwx {} ';'
282 $(AM_V_GEN)$(PERL) $(srcdir)/t/ax/deltree.pl t/*.dir t/*/*.dir */t/*.dir
284 # vim: ft=automake noet