Revert "Revert "Build System: Validate AndroidTest.xml Configs""
This reverts commit 054f210fd57b394c8fb1e5c8315ef7a553d0f5ee.
Reason for revert: Revert it again since BUG of 109736180 already be fixed.
Local verified for different build targets of
walleye_coverage-userdebug, marlin_coverage-userdebug
and make sure they can build pass.
BUG: 109736180
Test: lunch walleye_coverage-userdebug; make adbd_test
BUG: 73082610
Test: cd packages/apps/DocumentsUI/tests/; mma
Modify AndroidTest.xml to a not well-formed xml; mma
Then, it should build fail.
atest -v DocumentsUITests
Change-Id: Iadfcb28a4e3f685a66697de21f57ca5bdb8b7c9e
diff --git a/core/definitions.mk b/core/definitions.mk
index 092a778..90c6ecb 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2671,6 +2671,18 @@
$$(copy-file-to-target)
endef
+# Copies many xml files and check they are well-formed.
+# $(1): The xml files to copy. Each entry is a ':' separated src:dst pair.
+# Evaluates to the list of the dst files. (ie suitable for a dependency list.)
+define copy-many-xml-files-checked
+$(foreach f, $(1), $(strip \
+ $(eval _cmf_tuple := $(subst :, ,$(f))) \
+ $(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
+ $(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
+ $(eval $(call copy-xml-file-checked,$(_cmf_src),$(_cmf_dest))) \
+ $(_cmf_dest)))
+endef
+
# Copy the file only if it is a well-formed manifest file. For use viea $(eval)
# $(1): source file
# $(2): destination file
@@ -3116,15 +3128,20 @@
# For each suite:
# 1. Copy the files to the many suite output directories.
+# And for test config files, we'll check the .xml is well-formed before copy.
# 2. Add all the files to each suite's dependent files list.
# 3. Do the dependency addition to my_all_targets
-# Requires for each suite: my_compat_dist_$(suite) to be defined.
+# Requires for each suite: use my_compat_dist_config_$(suite) to define the test config.
+# and use my_compat_dist_$(suite) to define the others.
define create-suite-dependencies
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval COMPATIBILITY.$(suite).FILES := \
- $$(COMPATIBILITY.$(suite).FILES) $$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))))) \
+ $$(COMPATIBILITY.$(suite).FILES) $$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
+ $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))))) \
$(eval $(my_all_targets) : $(call copy-many-files, \
- $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_$(suite))))))
+ $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_$(suite))))) \
+ $(call copy-many-xml-files-checked, \
+ $(sort $(foreach suite,$(LOCAL_COMPATIBILITY_SUITE),$(my_compat_dist_config_$(suite))))))
endef
###########################################################