tests.mk 2.4 KB

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