Imported Upstream version 0.16.0
[platform/upstream/json-glib.git] / build / autotools / Makefile.am.gtest
1 # JSON-GLib - JSON reader and writer library
2
3 GTESTER        = gtester
4 GTESTER_REPORT = gtester-report
5
6 # initialize variables for unconditional += appending
7 EXTRA_DIST =
8 TEST_PROGS =
9
10 ### testing rules
11
12 # test: run all tests in cwd and subdirs
13 test: test-nonrecursive
14         @for subdir in $(SUBDIRS) . ; do \
15           test "$$subdir" = "." -o "$$subdir" = "po" || \
16           ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
17         done
18
19 # test-nonrecursive: run tests only in cwd
20 test-nonrecursive: ${TEST_PROGS}
21         @test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
22
23 # test-report: run tests in subdirs and generate report
24 # perf-report: run tests in subdirs with -m perf and generate report
25 # full-report: like test-report: with -m perf and -m slow
26 test-report perf-report full-report:    ${TEST_PROGS}
27         @test -z "${TEST_PROGS}" || { \
28           case $@ in \
29           test-report) test_options="-k";; \
30           perf-report) test_options="-k -m=perf";; \
31           full-report) test_options="-k -m=perf -m=slow";; \
32           esac ; \
33           if test -z "$$GTESTER_LOGDIR" ; then  \
34             ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
35           elif test -n "${TEST_PROGS}" ; then \
36             ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
37           fi ; \
38         }
39         @ ignore_logdir=true ; \
40           if test -z "$$GTESTER_LOGDIR" ; then \
41             GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
42             ignore_logdir=false ; \
43           fi ; \
44           if test -d "$(top_srcdir)/.git"; then \
45             export REVISION="`git describe`" ;  \
46           else \
47             export REVISION="$(JSON_VERSION) $(JSON_RELEASE_STATUS)" ; \
48           fi ; \
49           export TIMESTAMP=`date +%Y-%m-%dT%H:%M:%S%z` ; \
50           for subdir in $(SUBDIRS) . ; do \
51             test "$$subdir" = "." -o "$$subdir" = "po" || \
52             ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
53           done ; \
54           $$ignore_logdir || { \
55             echo '<?xml version="1.0"?>'                 > $@.xml ; \
56             echo '<report-collection>'                  >> $@.xml ; \
57             echo '<info>'                               >> $@.xml ; \
58             echo '  <package>$(PACKAGE)</package>'      >> $@.xml ; \
59             echo '  <version>$(JSON_VERSION)</version>' >> $@.xml ; \
60             echo "  <revision>$$REVISION</revision>"    >> $@.xml ; \
61             echo "  <date>$$TIMESTAMP</date>"           >> $@.xml ; \
62             echo '</info>'                              >> $@.xml ; \
63             for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
64               sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
65             done ; \
66             echo >> $@.xml ; \
67             echo '</report-collection>' >> $@.xml ; \
68             rm -rf "$$GTESTER_LOGDIR"/ ; \
69             ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
70           }
71 .PHONY: test test-report perf-report full-report test-nonrecursive
72
73 # run tests in cwd as part of make check
74 check-local: test-nonrecursive