gtester.mk 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # GLIB - Library of useful C routines
  2. # From http://git.gnome.org/browse/glib/tree/Makefile.decl
  3. GTESTER = gtester
  4. GTESTER_REPORT = gtester-report
  5. # initialize variables for unconditional += appending
  6. EXTRA_DIST =
  7. TEST_PROGS =
  8. ### testing rules
  9. # test: run all tests in cwd and subdirs
  10. test: ${TEST_PROGS}
  11. @test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
  12. @ for subdir in $(SUBDIRS) . ; do \
  13. test "$$subdir" = "." -o "$$subdir" = "po" || \
  14. ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
  15. done
  16. # test-report: run tests in subdirs and generate report
  17. # perf-report: run tests in subdirs with -m perf and generate report
  18. # full-report: like test-report: with -m perf and -m slow
  19. test-report perf-report full-report: ${TEST_PROGS}
  20. @test -z "${TEST_PROGS}" || { \
  21. case $@ in \
  22. test-report) test_options="-k";; \
  23. perf-report) test_options="-k -m=perf";; \
  24. full-report) test_options="-k -m=perf -m=slow";; \
  25. esac ; \
  26. if test -z "$$GTESTER_LOGDIR" ; then \
  27. ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
  28. elif test -n "${TEST_PROGS}" ; then \
  29. ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
  30. fi ; \
  31. }
  32. @ ignore_logdir=true ; \
  33. if test -z "$$GTESTER_LOGDIR" ; then \
  34. GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
  35. ignore_logdir=false ; \
  36. fi ; \
  37. for subdir in $(SUBDIRS) . ; do \
  38. test "$$subdir" = "." -o "$$subdir" = "po" || \
  39. ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
  40. done ; \
  41. $$ignore_logdir || { \
  42. echo '<?xml version="1.0"?>' > $@.xml ; \
  43. echo '<report-collection>' >> $@.xml ; \
  44. for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
  45. sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
  46. done ; \
  47. echo >> $@.xml ; \
  48. echo '</report-collection>' >> $@.xml ; \
  49. rm -rf "$$GTESTER_LOGDIR"/ ; \
  50. ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
  51. }
  52. .PHONY: test test-report perf-report full-report
  53. # run make test as part of make check
  54. check-local: test