summaryrefslogtreecommitdiffstats
path: root/testrunner
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2011-07-17 14:04:37 -0700
committerBrett Chabot <brettchabot@android.com>2011-07-17 14:06:20 -0700
commitecfcc7da8eb6db2c31bc45eb1d1b89ac231082a9 (patch)
treed0f943a8a26ebee8737f5ff44e4a5e88ba030bfd /testrunner
parente8ceb3f0b6829a07a12a6c45366ea53275cc5f60 (diff)
downloadandroid_development-ecfcc7da8eb6db2c31bc45eb1d1b89ac231082a9.tar.gz
android_development-ecfcc7da8eb6db2c31bc45eb1d1b89ac231082a9.tar.bz2
android_development-ecfcc7da8eb6db2c31bc45eb1d1b89ac231082a9.zip
Fix runtest --path for tests built against SDK.
Bug 4556556 Change-Id: I3f829cae8f9fc1e64b3a44ac9e306b13b3cead7c
Diffstat (limited to 'testrunner')
-rw-r--r--testrunner/android_manifest.py21
-rw-r--r--testrunner/test_defs/instrumentation_test.py11
-rwxr-xr-xtestrunner/test_defs/test_walker.py2
3 files changed, 31 insertions, 3 deletions
diff --git a/testrunner/android_manifest.py b/testrunner/android_manifest.py
index 5825118f1..6e8bd6c71 100644
--- a/testrunner/android_manifest.py
+++ b/testrunner/android_manifest.py
@@ -34,7 +34,7 @@ class AndroidManifest(object):
def __init__(self, app_path=None):
if app_path:
- self.ParseManifest(app_path)
+ self._ParseManifest(app_path)
def GetAppPath(self):
"""Retrieve file system path to this manifest file's directory."""
@@ -51,7 +51,7 @@ class AndroidManifest(object):
return None
return manifest.getAttribute('package')
- def ParseManifest(self, app_path):
+ def _ParseManifest(self, app_path):
"""Parse AndroidManifest.xml at the specified path.
Args:
@@ -108,3 +108,20 @@ class AndroidManifest(object):
"""Saves the manifest to disk."""
self._dom.writexml(open(self._manifest_path, mode='w'), encoding='utf-8')
+
+def CreateAndroidManifest(path):
+ """Factory method for creating a AndroidManifest.
+
+ Args:
+ path: the directory for the manifest file
+
+ Return:
+ the AndroidManifest or None if there was no file present
+ """
+ manifest_path = os.path.join(path, AndroidManifest.FILENAME)
+ if os.path.isfile(manifest_path):
+ manifest = AndroidManifest()
+ manifest._ParseManifest(path)
+ return manifest
+ else:
+ return None
diff --git a/testrunner/test_defs/instrumentation_test.py b/testrunner/test_defs/instrumentation_test.py
index 64182a41a..6f82456b3 100644
--- a/testrunner/test_defs/instrumentation_test.py
+++ b/testrunner/test_defs/instrumentation_test.py
@@ -199,6 +199,17 @@ class InstrumentationTestSuite(test_suite.AbstractTestSuite):
(total_count, fail_count, error_count))
+def HasInstrumentationTest(path):
+ """Determine if given path defines an instrumentation test.
+
+ Args:
+ path: file system path to instrumentation test.
+ """
+ manifest_parser = android_manifest.CreateAndroidManifest(path)
+ if manifest_parser:
+ return manifest_parser.GetInstrumentationNames()
+ return False
+
class InstrumentationTestFactory(test_suite.AbstractTestFactory):
"""A factory for creating InstrumentationTestSuites"""
diff --git a/testrunner/test_defs/test_walker.py b/testrunner/test_defs/test_walker.py
index de93c808e..298912518 100755
--- a/testrunner/test_defs/test_walker.py
+++ b/testrunner/test_defs/test_walker.py
@@ -191,7 +191,7 @@ class TestWalker(object):
"""
if android_mk_parser.HasGTest():
return gtest.GTestFactory(path, upstream_build_path=upstream_build_path)
- elif android_mk_parser.HasJavaLibrary('android.test.runner'):
+ elif instrumentation_test.HasInstrumentationTest(path):
return instrumentation_test.InstrumentationTestFactory(path,
upstream_build_path=upstream_build_path)
else: