Remove runtest hard dependency on test_defs.xml files.

Previously runtest would fail hard if development/test_runner/test_defs.xml
file was not present, even if it wasn't needed (ie running in --path mode).

This commit skips test_defs parsing if --path is specified, and only parses
development/test_runner/test_defs.xml if its present.

Bug 4556556

Change-Id: Ief2dbbdab5c7e82e5db64414392d6e2a564e815d
This commit is contained in:
Brett Chabot
2011-06-06 20:53:56 -07:00
parent 98ff2036ec
commit 3c9cefc70f

View File

@@ -195,18 +195,21 @@ class TestRunner(object):
Raises:
AbortError: If a fatal error occurred when parsing the tests.
"""
core_test_path = os.path.join(self._root_path, self._CORE_TEST_PATH)
try:
known_tests = test_defs.TestDefinitions()
known_tests.Parse(core_test_path)
# read all <android root>/vendor/*/tests/testinfo/test_defs.xml paths
vendor_tests_pattern = os.path.join(self._root_path,
self._VENDOR_TEST_PATH)
test_file_paths = glob.glob(vendor_tests_pattern)
for test_file_path in test_file_paths:
known_tests.Parse(test_file_path)
if os.path.isfile(self._options.user_tests_file):
known_tests.Parse(self._options.user_tests_file)
# only read tests when not in path mode
if not self._options.test_path:
core_test_path = os.path.join(self._root_path, self._CORE_TEST_PATH)
if os.path.isfile(core_test_path):
known_tests.Parse(core_test_path)
# read all <android root>/vendor/*/tests/testinfo/test_defs.xml paths
vendor_tests_pattern = os.path.join(self._root_path,
self._VENDOR_TEST_PATH)
test_file_paths = glob.glob(vendor_tests_pattern)
for test_file_path in test_file_paths:
known_tests.Parse(test_file_path)
if os.path.isfile(self._options.user_tests_file):
known_tests.Parse(self._options.user_tests_file)
return known_tests
except errors.ParseError:
raise errors.AbortError