make-rules/ant.mk
changeset 6608 a98160718cfc
parent 5682 94c0ca64c022
--- a/make-rules/ant.mk	Thu Aug 11 09:26:07 2016 -0700
+++ b/make-rules/ant.mk	Thu Aug 11 15:38:58 2016 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 ANT=/usr/bin/ant
@@ -56,7 +56,8 @@
 COMPONENT_SYSTEM_TEST_ENV += JAVA_HOME="$(JAVA_HOME)"
 COMPONENT_SYSTEM_TEST_CMD = $(ANT)
 
-# test the built source
+# Test the built source.  If the output file shows up in the environment or
+# arguments, don't redirect stdout/stderr to it.
 $(BUILD_DIR)/%/.tested-and-compared:    $(BUILD_DIR)/%/.built
 	$(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
 	$(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
@@ -65,7 +66,7 @@
 		$(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
 		$(COMPONENT_TEST_CMD) \
 		$(COMPONENT_TEST_ARGS) $(COMPONENT_TEST_TARGETS)) \
-		&> $(COMPONENT_TEST_OUTPUT)
+		$(if $(findstring $(COMPONENT_TEST_OUTPUT),$(COMPONENT_TEST_ENV)$(COMPONENT_TEST_ARGS)),,&> $(COMPONENT_TEST_OUTPUT))
 	$(COMPONENT_POST_TEST_ACTION)
 	$(COMPONENT_TEST_CREATE_TRANSFORMS)
 	$(COMPONENT_TEST_PERFORM_TRANSFORM)
@@ -86,7 +87,9 @@
 # Test the installed packages.  The targets above depend on .built which
 # means $(CLONEY) has already run.  System-test needs cloning but not
 # building; thus ideally, we would want to depend on .cloned here and below,
-# but since we don't have that, we depend on .prep and run $(CLONEY) here.
+# but since we don't have that, we depend on .prep and run $(CLONEY) here.  If
+# the output file shows up in the environment or arguments, don't redirect
+# stdout/stderr to it.
 $(BUILD_DIR)/%/.system-tested-and-compared:    $(SOURCE_DIR)/.prep
 	$(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
 	$(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
@@ -96,7 +99,7 @@
 		$(COMPONENT_SYSTEM_TEST_ENV_CMD) $(COMPONENT_SYSTEM_TEST_ENV) \
 		$(COMPONENT_SYSTEM_TEST_CMD) \
 		$(COMPONENT_SYSTEM_TEST_ARGS) $(COMPONENT_SYSTEM_TEST_TARGETS)) \
-		&> $(COMPONENT_TEST_OUTPUT)
+		$(if $(findstring $(COMPONENT_TEST_OUTPUT),$(COMPONENT_SYSTEM_TEST_ENV)$(COMPONENT_SYSTEM_TEST_ARGS)),,&> $(COMPONENT_TEST_OUTPUT))
 	$(COMPONENT_POST_SYSTEM_TEST_ACTION)
 	$(COMPONENT_TEST_CREATE_TRANSFORMS)
 	$(COMPONENT_TEST_PERFORM_TRANSFORM)