tg export: no need for merge or hook setup
[topgit/pro.git] / t / Makefile.sh
blobd21a14e8b5c2904affff92dc4f6fc7d847b0c274
1 # Makefile.sh - POSIX Makefile scripting adjunct for TopGit tests
2 # Copyright (C) 2017 Kyle J. McKay
3 # All rights reserved
4 # License GPL2
6 # Set MAKEFILESH_DEBUG to get:
7 # 1. All defined environment variales saved to Makefile.var
8 # 2. set -x
9 # 3. set -v if MAKEFILESH_DEBUG contains "v"
11 MKTOP=..
12 . "$MKTOP/Makefile.sh" # top-level defines
14 # prevent crazy "sh" implementations from exporting functions into environment
15 set +a
17 # wrap it up for safe returns
18 # "$@" is the current build target(s), if any
19 makefile() {
21 # config.sh is wrapped up for return safety
22 configsh
24 # config.sh may not unset these
25 : "${SHELL_PATH:=/bin/sh}" "${DIFF:=diff}" "${PROVE:=prove}"
26 : "${TEST_LINT=test-lint}"
27 TEST_RESULTS_DIRECTORY="${TEST_OUTPUT_DIRECTORY:+$TEST_OUTPUT_DIRECTORY/}test-results"
29 quotevar SHELL_PATH SHELL_PATH_SQ
30 quotevar PERL_PATH PERL_PATH_SQ
31 quotevar GIT_PATH GIT_PATH_SQ
32 quotevar TEST_RESULTS_DIRECTORY TEST_RESULTS_DIRECTORY_SQ
34 # Default list of tests is all t????-*.sh files
36 v_wildcard ALLT 't[0-9][0-9][0-9][0-9]-*.sh'
37 v_sort ALLT $ALLT
38 [ -n "$T" ] || T="$ALLT"
39 [ -n "$LITTESTS" ] || LINTTESTS="$T"
41 # Extra shell scripts to run through check-non-portable-shell.pl
42 # These will ALWAYS be "checked" whenever the test-lint target is made
43 # By default all $(T) test files are checked so they don't need to be
44 # in this list
46 v_wildcard LINTSCRIPTS '*.sh'
47 v_filter_out LINTSCRIPTS "$ALLT" $LINTSCRIPTS
48 v_sort LINTSCRIPTS $LINTSCRIPTS
50 if [ -z "$TESTLIB_NO_CACHE" ]; then
51 CACHE_SETUP='TESTLIB_CACHE="$$($(SHELL_PATH_SQ) ./test-lib.sh --cache $(TESTLIB_TEST_OPTS) 2>/dev/null || :)"'
52 CACHE_SETUP_TTY='! test -t 1 || { TESTLIB_FORCETTY=1 && export TESTLIB_FORCETTY; }; $(CACHE_SETUP)'
55 if [ -n "$TESTLIB_NO_CLEAN" ]; then
56 NOCLEANCMT='#'
59 [ -z "$MAKEFILESH_DEBUG" ] || {
60 printenv | LC_ALL=C grep '^[_A-Za-z][_A-Za-z0-9]*=' | LC_ALL=C sort
61 } >"Makefile.var"
63 # Force TG-TEST-SETTINGS to be updated now if needed
64 ${MAKE:-make} ${GNO_PD_OPT} -e -f Makefile.mak FORCE_SETTINGS_BUILD=FORCE TG-TEST-SETTINGS
66 # end of wrapper
69 . "$MKTOP/gnomake.sh" &&
70 set_gno_pd_opt &&
71 makefile "$@"