Index: build/android/pylib/gtest/test_runner.py |
diff --git a/build/android/pylib/gtest/test_runner.py b/build/android/pylib/gtest/test_runner.py |
index 734b12ef648a188da6b776f1874e2ba0c1c7f7de..436d08df680a018fb034ffb1b67f1a2992914095 100644 |
--- a/build/android/pylib/gtest/test_runner.py |
+++ b/build/android/pylib/gtest/test_runner.py |
@@ -5,8 +5,10 @@ |
import glob |
import logging |
import os |
+import sys |
from pylib import android_commands |
+from pylib import cmd_helper |
from pylib import constants |
from pylib import perf_tests_helper |
from pylib.android_commands import errors |
@@ -17,24 +19,61 @@ from pylib.utils import run_tests_helper |
import test_package_apk |
import test_package_executable |
+sys.path.insert( |
+ 0, os.path.join(constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client')) |
+import run_isolated |
-def _GetDataFilesForTestSuite(test_suite_basename): |
+ |
+_ISOLATE_FILE_PATHS = { |
+ 'base_unittests': 'base/base_unittests.isolate', |
+ #'net_unittests': 'net/net_unittests.isolate', |
+ #'unit_tests': 'chrome/unit_tests.isolate', |
+ #'content_browsertests': 'content/content_browsertests.isolate', |
+ #'content_unittests': 'content/content_unittests.isolate', |
+ } |
+_ISOLATE_SCRIPT = os.path.join( |
+ constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') |
+ |
+ |
+def _GetDataFilesForTestSuite(product_dir, test_suite_basename): |
"""Returns a list of data files/dirs needed by the test suite. |
Args: |
- test_suite_basename: The test suite basename for which to return file paths. |
+ product_dir: Absolute path to product directory (e.g. /../out/Debug). |
+ test_suite_basename: The test suite basename (e.g. base_unittests). |
Returns: |
A list of test file and directory paths. |
""" |
+ # TODO(frankf): *.isolated should be generated by gyp using foo_tests_run |
+ # targets. This is a stop-gap solution as currently there are no such |
+ # targets for content_unittests and content_browsertests. |
+ isolate_rel_path = _ISOLATE_FILE_PATHS.get(test_suite_basename) |
+ if isolate_rel_path: |
+ isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) |
+ isolated_abs_path = os.path.join( |
+ product_dir, '%s.isolated' % test_suite_basename) |
+ assert os.path.exists(isolate_abs_path) |
+ isolate_cmd = [ |
+ 'python', _ISOLATE_SCRIPT, |
+ 'check', |
+ '--isolate=%s' % isolate_abs_path, |
+ '--isolated=%s' % isolated_abs_path, |
+ '-V', 'PRODUCT_DIR=%s' % product_dir, |
+ '-V', 'OS=android', |
+ '--outdir=%s' % product_dir, |
+ ] |
+ assert not cmd_helper.RunCmd(isolate_cmd) |
+ with open(isolated_abs_path) as f: |
+ isolated_content = run_isolated.load_isolated(f.read()) |
+ assert isolated_content['os'] == 'android' |
+ return isolated_content['files'].keys() |
+ |
+ logging.info('Did not find an isolate file for the test suite.') |
# Ideally, we'd just push all test data. However, it has >100MB, and a lot |
# of the files are not relevant (some are used for browser_tests, others for |
# features not supported, etc..). |
- if test_suite_basename == 'base_unittests': |
- return [ |
- 'base/test/data/', |
- ] |
- elif test_suite_basename == 'unit_tests': |
+ if test_suite_basename == 'unit_tests': |
test_files = [ |
'base/test/data/', |
'chrome/test/data/download-test1.lib', |
@@ -280,7 +319,8 @@ class TestRunner(base_test_runner.BaseTestRunner): |
#override |
def PushDataDeps(self): |
self.tool.CopyFiles() |
- test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_basename) |
+ test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_dirname, |
+ self.test_package.test_suite_basename) |
if test_data: |
# Make sure SD card is ready. |
self.adb.WaitForSdCardReady(20) |