diff options
author | Dan Willemsen <dwillemsen@google.com> | 2020-01-21 14:37:29 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2020-01-21 15:22:19 -0800 |
commit | 481836ec30e459040a50ebc803578bfd930b4145 (patch) | |
tree | a4eeb7ccfdedef31e5c3998cb11ba3fee2cf1d81 | |
parent | 32f5dcf8718f33551c0706a47cfbc4ae9d8fface (diff) | |
download | robolectric-shadows-481836ec30e459040a50ebc803578bfd930b4145.tar.gz |
Only use $(shell) when necessary
This removes 35 $(shell) uses from AOSP, and there were only 101 total.
It also saves about 40% of the time we spent re-running shell commands
on every build (0.47s -> 0.28s).
Test: m nothing; m nothing; check out/verbose.log.gz for top shell cmds
Test: ROBOTEST_FILTER=CodeInspectionTest m nothing; check log
Change-Id: If33a74a2362787a30b38fb20f1d79ca420e38a52
-rw-r--r-- | run_robolectric_module_tests.mk | 8 | ||||
-rw-r--r-- | run_robotests.mk | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/run_robolectric_module_tests.mk b/run_robolectric_module_tests.mk index 6e49e7555..1c190e38b 100644 --- a/run_robolectric_module_tests.mk +++ b/run_robolectric_module_tests.mk @@ -13,12 +13,14 @@ test_source_files := $(call find-files-in-subdirs, $(test_source_directory), "*T test_source_files := $(filter-out org/robolectric/shadows/SQLiteCursorTest.java, $(test_source_files)) # Build the command that honors the test class filter, if any. -test_filter_command := $(if $(ROBOTEST_FILTER),grep -E "$(ROBOTEST_FILTER)",cat) +test_filter_command := $(if $(ROBOTEST_FILTER),grep -E "$(ROBOTEST_FILTER)",) # Convert the test source file paths into package names by removing ".java" extension and replacing "/" with "." -test_class_names := $(subst /,., $(basename $(test_source_files))) +test_class_names := $(sort $(subst /,., $(basename $(test_source_files)))) # Remove whitespace and sort the tests in alphabetical order. -test_class_names := $(sort $(shell echo '$(test_class_names)' | tr ' ' '\n' | $(test_filter_command))) +ifdef test_filter_command + test_class_names := $(sort $(shell echo '$(test_class_names)' | tr ' ' '\n' | $(test_filter_command))) +endif include $(BUILD_SYSTEM)/base_rules.mk diff --git a/run_robotests.mk b/run_robotests.mk index 2b076b05f..67a794846 100644 --- a/run_robotests.mk +++ b/run_robotests.mk @@ -51,7 +51,7 @@ ifneq ($(DISABLE_ROBO_RUN_TESTS),true) my_timeout := $(if $(LOCAL_ROBOTEST_TIMEOUT),$(LOCAL_ROBOTEST_TIMEOUT),600) # Command to filter the list of test classes. # If not specified, defaults to including all the tests. - my_test_filter_command := $(if $(ROBOTEST_FILTER),grep -E "$(ROBOTEST_FILTER)",cat) + my_test_filter_command := $(if $(ROBOTEST_FILTER),grep -E "$(ROBOTEST_FILTER)",) # The directory containing the sources. my_instrument_makefile_dir := $(dir $(ALL_MODULES.$(LOCAL_TEST_PACKAGE).MAKEFILE)) @@ -90,8 +90,10 @@ ifneq ($(DISABLE_ROBO_RUN_TESTS),true) LOCAL_ROBOTEST_FILES := $(call find-files-in-subdirs,$(LOCAL_PATH)/src,*Test.java,.) endif # Convert the paths into package names by removing .java extension and replacing "/" with "." - my_tests := $(subst /,.,$(basename $(LOCAL_ROBOTEST_FILES))) - my_tests := $(sort $(shell echo '$(my_tests)' | tr ' ' '\n' | $(my_test_filter_command))) + my_tests := $(sort $(subst /,.,$(basename $(LOCAL_ROBOTEST_FILES)))) + ifdef my_test_filter_command + my_tests := $(sort $(shell echo '$(my_tests)' | tr ' ' '\n' | $(my_test_filter_command))) + endif # The source jars containing the tests. my_srcs_jars := \ $(foreach lib, \ |