diff options
| author | Brett Chabot <brettchabot@google.com> | 2009-05-28 18:29:24 -0700 |
|---|---|---|
| committer | Brett Chabot <brettchabot@google.com> | 2009-05-29 13:35:13 -0700 |
| commit | ae68f1a8650415f97d8453c3b94897857695367b (patch) | |
| tree | df612ca890d95eba49cda16aa68800418923a32f /testrunner/coverage.py | |
| parent | 055fcd23fb79638dc7d738f2951594b87256564a (diff) | |
| download | android_development-ae68f1a8650415f97d8453c3b94897857695367b.tar.gz android_development-ae68f1a8650415f97d8453c3b94897857695367b.tar.bz2 android_development-ae68f1a8650415f97d8453c3b94897857695367b.zip | |
Add support for parsing code coverage file path to runtest and related cleanup.
This change is to adapt runtest to the InstrumentationTestRunner change which
dumps coverage data to the app's local data folder, instead of a fixed file on
the sdcard.
Also fixed adb_interace.StartInstrumentationForPackage, added better handling
when generating coverage for tests with unknown coverage targets, and reduced
the duplicate definitions of the "coverage_targets.xml" definition file.
Diffstat (limited to 'testrunner/coverage.py')
| -rwxr-xr-x | testrunner/coverage.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/testrunner/coverage.py b/testrunner/coverage.py index 39a2ceb21..c80eea0a4 100755 --- a/testrunner/coverage.py +++ b/testrunner/coverage.py @@ -44,16 +44,15 @@ class CoverageGenerator(object): # path to EMMA host jar, relative to Android build root _EMMA_JAR = os.path.join(_EMMA_BUILD_PATH, "lib", "emma.jar") _TEST_COVERAGE_EXT = "ec" - # default device-side path to code coverage results file - _DEVICE_COVERAGE_PATH = "/sdcard/coverage.ec" # root path of generated coverage report files, relative to Android build root _COVERAGE_REPORT_PATH = os.path.join("out", "emma") + _TARGET_DEF_FILE = "coverage_targets.xml" _CORE_TARGET_PATH = os.path.join("development", "testrunner", - "coverage_targets.xml") + _TARGET_DEF_FILE) # vendor glob file path patterns to tests, relative to android # build root _VENDOR_TARGET_PATH = os.path.join("vendor", "*", "tests", "testinfo", - "coverage_targets.xml") + _TARGET_DEF_FILE) # path to root of target build intermediates _TARGET_INTERMEDIATES_BASE_PATH = os.path.join("out", "target", "common", @@ -93,7 +92,7 @@ class CoverageGenerator(object): return False def ExtractReport(self, test_suite, - device_coverage_path=_DEVICE_COVERAGE_PATH, + device_coverage_path, output_path=None): """Extract runtime coverage data and generate code coverage report. @@ -122,8 +121,14 @@ class CoverageGenerator(object): report_path = os.path.join(output_path, test_suite.GetName()) target = self._targets_manifest.GetTarget(test_suite.GetTargetName()) - return self._GenerateReport(report_path, coverage_local_path, [target], - do_src=True) + if target is None: + msg = ["Error: test %s references undefined target %s." + % (test_suite.GetName(), test_suite.GetTargetName())] + msg.append(" Ensure target is defined in %s" % self._TARGET_DEF_FILE) + logger.Log("".join(msg)) + else: + return self._GenerateReport(report_path, coverage_local_path, [target], + do_src=True) return None def _GenerateReport(self, report_path, coverage_file_path, targets, |
