bdeadede021d9d9c7181c101d2a91dc643b6b966
[platform/upstream/automake.git] / lib / am / check.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright 2001 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.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; if not, write to the Free Software
16 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 ## 02111-1307, USA.
18
19 .PHONY: check-TESTS
20
21 check-TESTS: $(TESTS)
22         @failed=0; all=0; xfail=0; xpass=0; skip=0; \
23         srcdir=$(srcdir); export srcdir; \
24         list='$(TESTS)'; \
25         if test -n "$$list"; then \
26           for tst in $$list; do \
27             if test -f ./$$tst; then dir=./; \
28 ## Note: Solaris 2.7 seems to expand TESTS using VPATH.  That's
29 ## why we also try `dir='
30             elif test -f $$tst; then dir=; \
31             else dir="$(srcdir)/"; fi; \
32             if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
33 ## Success
34               all=`expr $$all + 1`; \
35               case " $(XFAIL_TESTS) " in \
36               *" $$tst "*) \
37                 xpass=`expr $$xpass + 1`; \
38                 failed=`expr $$failed + 1`; \
39                 echo "XPASS: $$tst"; \
40               ;; \
41               *) \
42                 echo "PASS: $$tst"; \
43               ;; \
44               esac; \
45             elif test $$? -ne 77; then \
46 ## Failure
47               all=`expr $$all + 1`; \
48               case " $(XFAIL_TESTS) " in \
49               *" $$tst "*) \
50                 xfail=`expr $$xfail + 1`; \
51                 echo "XFAIL: $$tst"; \
52               ;; \
53               *) \
54                 failed=`expr $$failed + 1`; \
55                 echo "FAIL: $$tst"; \
56               ;; \
57               esac; \
58             else \
59 ## Skipped
60               skip=`expr $$skip + 1`; \
61               echo "SKIP: $$tst"; \
62             fi; \
63           done; \
64 ## Prepare the banner
65           if test "$$failed" -eq 0; then \
66             if test "$$xfail" -eq 0; then \
67               banner="All $$all tests passed"; \
68             else \
69               banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
70             fi; \
71           else \
72             if test "$$xpass" -eq 0; then \
73               banner="$$failed of $$all tests failed"; \
74             else \
75               banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
76             fi; \
77           fi; \
78 ## DASHES should contain the largest line of the banner.
79           dashes="$$banner"; \
80           skipped=""; \
81           if test "$$skip" -ne 0; then \
82             skipped="($$skip tests were not run)"; \
83             test `echo "$$skipped" | wc -c` -gt `echo "$$banner" | wc -c` && \
84               dashes="$$skipped"; \
85           fi; \
86           report=""; \
87           if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
88             report="Please report to $(PACKAGE_BUGREPORT)"; \
89             test `echo "$$report" | wc -c` -gt `echo "$$banner" | wc -c` && \
90               dashes="$$report"; \
91           fi; \
92           dashes=`echo "$$dashes" | sed s/./=/g`; \
93           echo "$$dashes"; \
94           echo "$$banner"; \
95           test -n "$$skipped" && echo "$$skipped"; \
96           test -n "$$report" && echo "$$report"; \
97           echo "$$dashes"; \
98           test "$$failed" -eq 0; \
99         else :; fi