summaryrefslogtreecommitdiff
path: root/lib/am/serial-tests.mk
blob: d6b9c666365803fd03756684f5562fbd29c5029d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
## automake - create Makefile.in from Makefile.am
## Copyright (C) 2001-2014 Free Software Foundation, Inc.

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.

## Obsolescent serial testsuite driver.

ifdef EXEEXT
## This is suboptimal, but we need to preserve the order of $(TESTS).
am.test-suite.cook-with-exeext.helper = \
    $(if $(filter $(am.all-progs), $1), $1$(EXEEXT), $1)
am.test-suite.cook-with-exeext = \
    $(strip $(foreach t, $1, $(call $0.helper, $t)))
else
am.test-suite.cook-with-exeext = $(strip $1)
endif

# TESTS can contain compiled programs, in which case we might have
# to account for $(EXEEXT) appending.  For matching purposes, we
# need to adjust XFAIL_TESTS as well.
am__cooked_tests = \
  $(call am.test-suite.cook-with-exeext, $(TESTS))
am__cooked_xfail_tests = \
  $(call am.test-suite.cook-with-exeext, $(XFAIL_TESTS))

.PHONY: check-TESTS
check-TESTS: $(am__cooked_tests)
	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
	srcdir=$(srcdir); export srcdir; \
	list='$(am__cooked_tests)'; \
	$(am.test-suite.tty-colors); \
	is_xfail_test () { \
	  case " $(strip $(am__cooked_xfail_tests)) " in \
	    *" $$tst "*) return 0;; \
	    *) return 1;; \
	  esac; \
	}; \
	test -n "$$list" || exit 0; \
## Run the tests one by one in series, collecting their results.
	for tst in $$list; do \
	  if test -f ./$$tst; then dir=./; \
## For VPATH support.
	  else dir="$(srcdir)/"; fi; \
	  if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \
## Success.
	    all=`expr $$all + 1`; \
	    if is_xfail_test; then \
	      xpass=`expr $$xpass + 1`; \
	      failed=`expr $$failed + 1`; \
	      col=$$red; res=XPASS; \
	    else \
	      col=$$grn; res=PASS; \
	    fi; \
	  elif test $$? -ne 77; then \
## Failure.  Expected or unexpected?
	    all=`expr $$all + 1`; \
	    if is_xfail_test; then \
## Expected failure (XFAIL).
	      xfail=`expr $$xfail + 1`; \
	      col=$$lgn; res=XFAIL; \
	    else \
## Unexpected failure (FAIL).
	      failed=`expr $$failed + 1`; \
	      col=$$red; res=FAIL; \
	    fi; \
	  else \
## Test skipped.
	    skip=`expr $$skip + 1`; \
	    col=$$blu; res=SKIP; \
	  fi; \
## Report this single result on stdout.
	  echo "$${col}$$res$${std}: $$tst"; \
	done; \
## Done running the tests.  Will now have to display the global
## outcome, with proper formatting.
## Let's start preparing the banner.
	if test "$$all" -eq 1; then \
	  tests="test"; \
	  All=""; \
	else \
	  tests="tests"; \
	  All="All "; \
	fi; \
	if test "$$failed" -eq 0; then \
	  if test "$$xfail" -eq 0; then \
	    banner="$$All$$all $$tests passed"; \
	  else \
	    if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
	    banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
	  fi; \
	else \
	  if test "$$xpass" -eq 0; then \
	    banner="$$failed of $$all $$tests failed"; \
	  else \
	    if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
	    banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
	  fi; \
	fi; \
## DASHES should contain the largest line of the banner.
	dashes="$$banner"; \
	skipped=""; \
	if test "$$skip" -ne 0; then \
	  if test "$$skip" -eq 1; then \
	    skipped="($$skip test was not run)"; \
	  else \
	    skipped="($$skip tests were not run)"; \
	  fi; \
	  test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
	    dashes="$$skipped"; \
	fi; \
	report=""; \
	if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
	  report="Please report to $(PACKAGE_BUGREPORT)"; \
	  test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
	    dashes="$$report"; \
	fi; \
	dashes=`echo "$$dashes" | sed s/./=/g`; \
	if test "$$failed" -eq 0; then \
	  col="$$grn"; \
	else \
	  col="$$red"; \
	fi; \
## Multi line coloring is problematic with "less -R", so we really need
## to color each line individually.
	echo "$${col}$$dashes$${std}"; \
	echo "$${col}$$banner$${std}"; \
	test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
	test -z "$$report" || echo "$${col}$$report$${std}"; \
	echo "$${col}$$dashes$${std}"; \
	test "$$failed" -eq 0 || exit 1