Allow Soong to autogenerate test configs
Move the configuration for autogenerating test configs into Soong,
and add LOCAL_FULL_TEST_CONFIG so that Soong can specify the full
path to a generated test config.
Also add a java junit test config template.
Bug: 70770641
Test: m checkbuild
Test: atest CtsUiRenderingTestCases
Test: atest junit-params-test
Change-Id: I2e64bc33c949ab7b342be518f94a81a186fe9c07
diff --git a/core/base_rules.mk b/core/base_rules.mk
index db09670..31e8bad 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -583,10 +583,12 @@
$(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \
$(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(s):$(dir)/$(n)))))
- ifeq (,$(LOCAL_TEST_CONFIG))
- test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml)
- else
+ ifneq (,$(LOCAL_FULL_TEST_CONFIG))
+ test_config := $(LOCAL_FULL_TEST_CONFIG)
+ else ifneq (,$(LOCAL_TEST_CONFIG))
test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG)
+ else
+ test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml)
endif
ifeq (,$(test_config))
ifneq (true,$(is_native))
@@ -639,6 +641,19 @@
endif
endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
+# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by copying it to
+# the location autogenerated test configs use and setting the flag in
+# module-info.json
+ifdef LOCAL_FULL_TEST_CONFIG
+ ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+ my_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
+ $(eval $(call copy-one-file,$(LOCAL_FULL_TEST_CONFIG),$(my_test_config_file)))
+ $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_test_config_file))
+ ALL_MODULES.$(my_register_name).auto_test_config := true
+ my_test_config_file :=
+ endif
+endif
+
ifneq ($(my_test_data_file_pairs),)
$(foreach pair, $(my_test_data_file_pairs), \
$(eval parts := $(subst :,$(space),$(pair))) \