From 6dbf1183bd5fea6c3ff1a68a518903aac25585b9 Mon Sep 17 00:00:00 2001 From: Bernard Davison Date: Mon, 5 Mar 2012 15:08:23 +1100 Subject: [PATCH] Adding JUnit result output The JUnit results can be added by specifying JUNIT=1 from the make command line. This is important as the Bamboo server can read JUnit results and include them in the build reports. This requires that the Perl module TAP::Formatter::JUnit is installed on the host that the command is run on. The JUnit results are created under tests/results and have the name ABC.junit.xml --- Makefile | 1 + tests/Makefile | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d2ead921cb..d54fb90639 100644 --- a/Makefile +++ b/Makefile @@ -238,6 +238,7 @@ clean: $(Q)find . -mindepth 2 -name Makefile -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \; $(Q)find . -name '*~' -exec rm -f {} \; $(Q)rm -f paparazzi sw/simulator/launchsitl + $(Q)rm -rf tests/results/* cleanspaces: find ./sw/airborne -name '*.[ch]' -exec sed -i {} -e 's/[ \t]*$$//' \; diff --git a/tests/Makefile b/tests/Makefile index d801c6f73a..cf84e47478 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,10 +1,19 @@ +Q = @ PERL = perl -TEST_VERBOSE=0 -ifeq ($(AIRCRAFT),) -AIRCRAFT=* +TEST_VERBOSE = 0 +ifeq ($(TARGET_BOARD),) + TARGET_BOARD = * +endif +TEST_FILES := $(shell ls $(TARGET_BOARD)/*.t) + +ifneq ($(JUNIT),) + PERLENV=PERL_TEST_HARNESS_DUMP_TAP=$(PAPARAZZI_SRC)/tests/results + RUNTESTS=use TAP::Harness; TAP::Harness->new({ formatter_class => 'TAP::Formatter::JUnit', merge => 1, } )->runtests(qw($(TEST_FILES))) +else + PERLENV= + RUNTESTS=use TAP::Harness;TAP::Harness->new()->runtests(qw($(TEST_FILES))) endif -TEST_FILES = $(AIRCRAFT)/*.t test: - $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES) + $(Q)$(PERLENV) $(PERL) "-e" "$(RUNTESTS)"