aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-06-19 15:55:05 -0700
committerDan Willemsen <dwillemsen@google.com>2018-06-19 16:23:05 -0700
commit31c4a3ac40b03a14ce79daa19667c3e100dc843e (patch)
tree4c32a601d8c1f4564a2ca5d64ddd40137b43e4b4
parent701d053c14db47c9f83844f148ce4e8da58bc3d2 (diff)
downloadrobolectric-shadows-31c4a3ac40b03a14ce79daa19667c3e100dc843e.tar.gz
Stop declaring real files as phony
I've added some logic into Kati to attempt to prevent this type of thing, since in the majority of cases, we expected a command to only run if one of its dependencies has changed. Workaround this specific case by declaring an output that is never written. DO NOT use this elsewhere without permission. There will eventually be a check for this workaround as well, but by that time we'll probably be ready to mark rules that should not be cached. Test: m RunSettingsLibRoboTests; m RunSettingsLibRoboTests Test: m Run_robolectric_utils_tests; m Run_robolectric_utils_tests Change-Id: Ifa9be1b299c0188b9e5f5886a4c80a21de42b0a1
-rw-r--r--robotest-internal.mk13
-rw-r--r--run_robolectric_module_tests.mk9
2 files changed, 16 insertions, 6 deletions
diff --git a/robotest-internal.mk b/robotest-internal.mk
index c0731c144..535d2fe69 100644
--- a/robotest-internal.mk
+++ b/robotest-internal.mk
@@ -13,7 +13,10 @@ my_target_output := $(intermediates)/$(my_filename_stem)-output.txt
my_target_retval := $(intermediates)/$(my_filename_stem)-retval.txt
# We should always re-run the tests, even if nothing has changed.
-.PHONY: $(my_target_output) $(my_target_retval)
+# So until the build system has a dedicated "no cache" option, claim
+# to write a file that is never produced.
+my_target_nocache := $(intermediates)/$(my_filename_stem)-nocache
+
# Private variables.
$(my_target_output): PRIVATE_MODULE := $(LOCAL_MODULE)
$(my_target_output): PRIVATE_TESTS := $(my_tests)
@@ -24,15 +27,17 @@ $(my_target_output): PRIVATE_ROBOLECTRIC_SCRIPT_PATH := $(my_robolectric_script_
$(my_target_output): PRIVATE_TARGET_MESSAGE := $(my_target_message)
$(my_target_output): PRIVATE_TARGET_OUTPUT := $(my_target_output)
$(my_target_output): PRIVATE_TARGET_RETVAL := $(my_target_retval)
+$(my_target_output): PRIVATE_TARGET_NOCACHE := $(my_target_nocache)
$(my_target_output): PRIVATE_TIMEOUT := $(my_timeout)
$(my_target_output): PRIVATE_XML_OUTPUT_FILE := $(my_target_xml)
-$(my_target_output): .KATI_IMPLICIT_OUTPUTS := $(my_target_xml) $(my_target_retval)
+$(my_target_output): .KATI_IMPLICIT_OUTPUTS := $(my_target_xml) $(my_target_retval) $(my_target_nocache)
# Runs the Robolectric tests and saves the output and return value.
$(my_target_output): $(my_jars)
@echo "host Robolectric: $(PRIVATE_MODULE)"
# Run `touch` to always create the output XML file, so the build doesn't break even if the
# runner failed to create the XML output
$(hide) touch "$(PRIVATE_XML_OUTPUT_FILE)"
+ $(hide) rm -f "$(PRIVATE_TARGET_NOCACHE)"
$(hide) \
PRIVATE_INTERMEDIATES="$(dir $@)" \
PRIVATE_JARS="$(PRIVATE_JARS)" \
@@ -52,8 +57,6 @@ $(my_target_output): $(my_jars)
wrap \
$(PRIVATE_ROBOLECTRIC_SCRIPT_PATH)/robotest.sh
-# This does not actually generate a file.
-.PHONY: $(my_target)
# Private variables.
$(my_target): PRIVATE_MODULE := $(LOCAL_MODULE)
$(my_target): PRIVATE_TARGET_OUTPUT := $(my_target_output)
@@ -74,6 +77,7 @@ $(my_target): $(my_target_output) $(my_target_xml)
if [ "$(strip $(PRIVATE_FAILURE_FATAL))" = true ]; then \
exit "$$result"; \
fi
+ $(hide) touch $@
# Add the output of the tests to the dist list, so that we will include it even
# if the tests fail.
@@ -85,4 +89,5 @@ $(call dist-for-goals, $(my_target), \
my_target_output :=
my_target_retval :=
my_target_xml :=
+my_target_nocache :=
my_filename_stem :=
diff --git a/run_robolectric_module_tests.mk b/run_robolectric_module_tests.mk
index 0526bdba5..0b666fc06 100644
--- a/run_robolectric_module_tests.mk
+++ b/run_robolectric_module_tests.mk
@@ -68,10 +68,15 @@ $(LOCAL_BUILT_MODULE): private_host_jdk_tools_jar := $(HOST_JDK_TOOLS_JAR)
$(LOCAL_BUILT_MODULE): private_android_all_dir := $(android_all_target_dir)
$(LOCAL_BUILT_MODULE): private_classpath_jars := $(call normalize-path-list, $(classpath_jars))
-.PHONY: $(LOCAL_BUILT_MODULE)
+# Always re-run the tests, even if nothing has changed.
+# Until the build system has a dedicated "no cache" option, claim to write
+# a file that is never produced.
+$(LOCAL_BUILT_MODULE): private_nocache := $(LOCAL_BUILT_MODULE).nocache
+$(LOCAL_BUILT_MODULE): .KATI_IMPLICIT_OUTPUTS := $(LOCAL_BUILT_MODULE).nocache
# Define the basic recipe for building this module to execute the tests.
$(LOCAL_BUILT_MODULE): $(copy_test_resource_files) $(copy_android_all_jars) $(classpath_jars)
+ $(hide) rm -f "$(private_nocache)"
$(hide) $(private_java) \
-Drobolectric.offline=true \
-Drobolectric.dependency.dir=$(private_android_all_dir) \
@@ -79,4 +84,4 @@ $(LOCAL_BUILT_MODULE): $(copy_test_resource_files) $(copy_android_all_jars) $(cl
$(private_debug_test_args) \
-cp $(private_host_jdk_tools_jar):$(private_test_base_dir):$(private_classpath_jars) \
org.junit.runner.JUnitCore \
- $(private_test_class_names) \ No newline at end of file
+ $(private_test_class_names)