Distinguish in-broker and standalone tests bug23568
authorDavid Wragg <david@rabbitmq.com>
Tue, 01 Feb 2011 16:01:12 +0000
branchbug23568
changeset 252a3611ba1bb84
parent 251 f083a765ca23
child 254 acd4d74aff7a
Distinguish in-broker and standalone tests
do-package.mk
umbrella.mk
     1.1 --- a/do-package.mk	Tue Feb 01 14:54:28 2011 +0000
     1.2 +++ b/do-package.mk	Tue Feb 01 16:01:12 2011 +0000
     1.3 @@ -280,18 +280,22 @@
     1.4  # Commands to run the package's test suite
     1.5  #
     1.6  # $(1): Extra .ezs to copy into the plugins dir
     1.7 -define run_tests
     1.8 +define run_in_broker_tests
     1.9 +$(if $(IN_BROKER_TEST_COMMANDS)$(IN_BROKER_TEST_SCRIPTS),$(call run_in_broker_tests_aux,$1))
    1.10 +endef
    1.11 +
    1.12 +define run_in_broker_tests_aux
    1.13  	$(call run_broker,'-pa $(TEST_EBIN_DIR) -coverage directories ["$(EBIN_DIR)"$(COMMA)"$(TEST_EBIN_DIR)"]',,$(1)) &
    1.14  	sleep 5
    1.15  	echo > $(TEST_TMPDIR)/rabbit-test-output && \
    1.16 -	if $(foreach CMD,$(TEST_COMMANDS), \
    1.17 +	if $(foreach CMD,$(IN_BROKER_TEST_COMMANDS), \
    1.18  	     echo >> $(TEST_TMPDIR)/rabbit-test-output && \
    1.19  	     echo "$(CMD)." \
    1.20                 | tee -a $(TEST_TMPDIR)/rabbit-test-output \
    1.21                 | $(ERL_CALL) $(ERL_CALL_OPTS) \
    1.22                 | tee -a $(TEST_TMPDIR)/rabbit-test-output \
    1.23 -               | egrep "{ok, " >/dev/null && ) \
    1.24 -	    $(foreach SCRIPT,$(TEST_SCRIPTS),$(SCRIPT) && ) : ; then \
    1.25 +               | egrep "{ok, " >/dev/null &&) \
    1.26 +	    $(foreach SCRIPT,$(IN_BROKER_TEST_SCRIPTS),$(SCRIPT) &&) : ; then \
    1.27  	  echo "\nPASSED\n" ; \
    1.28  	else \
    1.29  	  cat $(TEST_TMPDIR)/rabbit-test-output ; \
    1.30 @@ -314,17 +318,30 @@
    1.31  
    1.32  # A hook to allow packages to verify that prerequisites are satisfied
    1.33  # before running tests.
    1.34 -.PHONY: $(PACKAGE_DIR)+pre-test-checks
    1.35 -$(PACKAGE_DIR)+pre-test-checks::
    1.36 +.PHONY: $(PACKAGE_DIR)+pre-test
    1.37 +$(PACKAGE_DIR)+pre-test::
    1.38  
    1.39 +# Runs the package's tests that operate within (or in conjuction with)
    1.40 +# a running broker.
    1.41 +.PHONY: $(PACKAGE_DIR)+in-broker-test
    1.42 +$(PACKAGE_DIR)+in-broker-test: $(PACKAGE_DIR)/dist/.done $(TEST_EBIN_BEAMS) $(PACKAGE_DIR)+pre-test
    1.43 +	$(call run_in_broker_tests)
    1.44 +
    1.45 +# Running the coverage tests requires Erlang/OTP R14. Note that
    1.46 +# coverage only covers the in-broker tests.
    1.47 +.PHONY: $(PACKAGE_DIR)+coverage
    1.48 +$(PACKAGE_DIR)+coverage: $(PACKAGE_DIR)/dist/.done $(COVERAGE_PATH)/dist/.done $(TEST_EBIN_BEAMS) $(PACKAGE_DIR)+pre-test assert-erlang-r14
    1.49 +	$(call run_in_broker_tests,$(COVERAGE_PATH)/dist/*.ez)
    1.50 +
    1.51 +# Runs the package's tests that don't need a running broker
    1.52 +.PHONY: $(PACKAGE_DIR)+standalone-test
    1.53 +$(PACKAGE_DIR)+standalone-test: $(PACKAGE_DIR)/dist/.done $(TEST_EBIN_BEAMS) $(PACKAGE_DIR)+pre-test
    1.54 +	$$(if $(STANDALONE_TEST_COMMANDS),$$(foreach CMD,$(STANDALONE_TEST_COMMANDS),ERL_LIBS=$(PACKAGE_DIR)/dist $(ERL) -pa $(TEST_EBIN_DIR) -eval "$$(CMD)" -eval 'init:stop()' &&) :)
    1.55 +	$$(if $(STANDALONE_TEST_SCRIPTS),$$(foreach SCRIPT,$(STANDALONE_TEST_SCRIPTS),$$(SCRIPT) &&) :)
    1.56 +
    1.57 +# Run all the package's tests
    1.58  .PHONY: $(PACKAGE_DIR)+test
    1.59 -$(PACKAGE_DIR)+test: $(PACKAGE_DIR)/dist/.done $(TEST_EBIN_BEAMS) $(PACKAGE_DIR)+pre-test-checks
    1.60 -	$(call run_tests)
    1.61 -
    1.62 -# Running the coverage tests required Erlang/OTP R14
    1.63 -.PHONY: $(PACKAGE_DIR)+coverage
    1.64 -$(PACKAGE_DIR)+coverage: $(PACKAGE_DIR)/dist/.done $(COVERAGE_PATH)/dist/.done $(TEST_EBIN_BEAMS) $(PACKAGE_DIR)+pre-test-checks assert-erlang-r14
    1.65 -	$(call run_tests,$(COVERAGE_PATH)/dist/*.ez)
    1.66 +$(PACKAGE_DIR)+test:: $(PACKAGE_DIR)+standalone-test $(PACKAGE_DIR)+in-broker-test
    1.67  
    1.68  endef
    1.69  $(eval $(package_targets))
     2.1 --- a/umbrella.mk	Tue Feb 01 14:54:28 2011 +0000
     2.2 +++ b/umbrella.mk	Tue Feb 01 16:01:12 2011 +0000
     2.3 @@ -20,11 +20,12 @@
     2.4  .PHONY: clean-local
     2.5  clean-local: $(PACKAGE_DIR)+clean
     2.6  
     2.7 -# Test the package
     2.8 +# Runs the package's tests
     2.9  .PHONY: test
    2.10  test: $(PACKAGE_DIR)+test
    2.11  
    2.12 -# Test the package with code coverage recording on
    2.13 +# Test the package with code coverage recording on.  Note that
    2.14 +# coverage only covers the in-broker tests.
    2.15  .PHONY: coverage
    2.16  coverage: $(PACKAGE_DIR)+coverage
    2.17