Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import tempfile | 7 import tempfile |
| 8 | 8 |
| 9 from devil.utils import cmd_helper | 9 from devil.utils import cmd_helper |
| 10 from pylib import constants | 10 from pylib import constants |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 #override | 24 #override |
| 25 def SetUp(self): | 25 def SetUp(self): |
| 26 pass | 26 pass |
| 27 | 27 |
| 28 #override | 28 #override |
| 29 def RunTests(self): | 29 def RunTests(self): |
| 30 with tempfile.NamedTemporaryFile() as json_file: | 30 with tempfile.NamedTemporaryFile() as json_file: |
| 31 java_script = os.path.join( | 31 java_script = os.path.join( |
| 32 constants.GetOutDirectory(), 'bin', 'helper', | 32 constants.GetOutDirectory(), 'bin', 'helper', |
| 33 self._test_instance.suite) | 33 self._test_instance.suite) |
|
agrieve
2017/03/30 17:09:54
whoops, random whitespace change.
ScottK
2017/04/04 21:03:02
Fixed, but I've also split this to another cr/2788
| |
| 34 command = [java_script] | 34 command = [java_script] |
| 35 | 35 |
| 36 # Add Jar arguments. | 36 # Add Jar arguments. |
| 37 jar_args = ['-test-jars', self._test_instance.suite + '.jar', | 37 jar_args = ['-test-jars', self._test_instance.suite + '.jar', |
| 38 '-json-results-file', json_file.name] | 38 '-json-results-file', json_file.name] |
| 39 if self._test_instance.test_filter: | 39 if self._test_instance.test_filter: |
| 40 jar_args.extend(['-gtest-filter', self._test_instance.test_filter]) | 40 jar_args.extend(['-gtest-filter', self._test_instance.test_filter]) |
| 41 if self._test_instance.package_filter: | 41 if self._test_instance.package_filter: |
| 42 jar_args.extend(['-package-filter', | 42 jar_args.extend(['-package-filter', |
| 43 self._test_instance.package_filter]) | 43 self._test_instance.package_filter]) |
| 44 if self._test_instance.runner_filter: | 44 if self._test_instance.runner_filter: |
| 45 jar_args.extend(['-runner-filter', self._test_instance.runner_filter]) | 45 jar_args.extend(['-runner-filter', self._test_instance.runner_filter]) |
| 46 command.extend(['--jar-args', '"%s"' % ' '.join(jar_args)]) | 46 command.extend(['--jar-args', '"%s"' % ' '.join(jar_args)]) |
| 47 | 47 |
| 48 # Add JVM arguments. | 48 # Add JVM arguments. |
| 49 jvm_args = [] | 49 jvm_args = [] |
| 50 # TODO(mikecase): Add a --robolectric-dep-dir arg to test runner. | 50 # TODO(mikecase): Add a --robolectric-dep-dir arg to test runner. |
| 51 # Have this arg set by GN in the generated test runner scripts. | 51 # Have this arg set by GN in the generated test runner scripts. |
| 52 jvm_args += [ | 52 jvm_args += [ |
| 53 '-Drobolectric.dependency.dir=%s' % | 53 '-Drobolectric.dependency.dir=%s' % os.path.join( |
| 54 os.path.join(constants.GetOutDirectory(), | 54 constants.GetOutDirectory(), 'lib.java', 'third_party', |
| 55 'lib.java', 'third_party', 'robolectric')] | 55 'robolectric'), |
| 56 '-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT, | |
| 57 ] | |
| 56 if self._test_instance.coverage_dir: | 58 if self._test_instance.coverage_dir: |
| 57 if not os.path.exists(self._test_instance.coverage_dir): | 59 if not os.path.exists(self._test_instance.coverage_dir): |
| 58 os.makedirs(self._test_instance.coverage_dir) | 60 os.makedirs(self._test_instance.coverage_dir) |
| 59 elif not os.path.isdir(self._test_instance.coverage_dir): | 61 elif not os.path.isdir(self._test_instance.coverage_dir): |
| 60 raise Exception('--coverage-dir takes a directory, not file path.') | 62 raise Exception('--coverage-dir takes a directory, not file path.') |
| 61 jvm_args.append('-Demma.coverage.out.file=%s' % os.path.join( | 63 jvm_args.append('-Demma.coverage.out.file=%s' % os.path.join( |
| 62 self._test_instance.coverage_dir, | 64 self._test_instance.coverage_dir, |
| 63 '%s.ec' % self._test_instance.suite)) | 65 '%s.ec' % self._test_instance.suite)) |
| 64 if jvm_args: | 66 if jvm_args: |
| 65 command.extend(['--jvm-args', '"%s"' % ' '.join(jvm_args)]) | 67 command.extend(['--jvm-args', '"%s"' % ' '.join(jvm_args)]) |
| 66 | 68 |
| 67 cmd_helper.RunCmd(command) | 69 cmd_helper.RunCmd(command) |
| 68 results_list = json_results.ParseResultsFromJson( | 70 results_list = json_results.ParseResultsFromJson( |
| 69 json.loads(json_file.read())) | 71 json.loads(json_file.read())) |
| 70 | 72 |
| 71 test_run_results = base_test_result.TestRunResults() | 73 test_run_results = base_test_result.TestRunResults() |
| 72 test_run_results.AddResults(results_list) | 74 test_run_results.AddResults(results_list) |
| 73 | 75 |
| 74 return [test_run_results] | 76 return [test_run_results] |
| 75 | 77 |
| 76 #override | 78 #override |
| 77 def TearDown(self): | 79 def TearDown(self): |
| 78 pass | 80 pass |
| OLD | NEW |