Commit a92e7bd9 authored by scottkirkwood's avatar scottkirkwood Committed by Commit bot

Add a way to get the test data folder from junit.

BUG=

Review-Url: https://codereview.chromium.org/2788733002
Cr-Commit-Position: refs/heads/master@{#463328}
parent dfd67dbe
......@@ -28,9 +28,8 @@ class LocalMachineJunitTestRun(test_run.TestRun):
#override
def RunTests(self):
with tempfile.NamedTemporaryFile() as json_file:
java_script = os.path.join(
constants.GetOutDirectory(), 'bin', 'helper',
self._test_instance.suite)
java_script = os.path.join(constants.GetOutDirectory(), 'bin', 'helper',
self._test_instance.suite)
command = [java_script]
# Add Jar arguments.
......@@ -50,9 +49,11 @@ class LocalMachineJunitTestRun(test_run.TestRun):
# TODO(mikecase): Add a --robolectric-dep-dir arg to test runner.
# Have this arg set by GN in the generated test runner scripts.
jvm_args += [
'-Drobolectric.dependency.dir=%s' %
os.path.join(constants.GetOutDirectory(),
'lib.java', 'third_party', 'robolectric')]
'-Drobolectric.dependency.dir=%s' % os.path.join(
constants.GetOutDirectory(), 'lib.java', 'third_party',
'robolectric'),
'-Ddir.source.root=%s' % constants.DIR_SOURCE_ROOT,
]
if self._test_instance.coverage_dir:
if not os.path.exists(self._test_instance.coverage_dir):
os.makedirs(self._test_instance.coverage_dir)
......
......@@ -26,6 +26,7 @@ java_library("junit_test_support") {
"java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java",
"java/src/org/chromium/testing/local/PackageFilter.java",
"java/src/org/chromium/testing/local/RunnerFilter.java",
"java/src/org/chromium/testing/local/TestDir.java",
]
deps = [
"//third_party/junit",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.testing.local;
import java.io.File;
/**
* Tools to get the junit test path.
*/
public class TestDir {
private static final String TEST_FOLDER = "/chrome/test/data/";
/**
* Construct the full path of a test data file.
* @param path Pathname relative to chrome/test/data.
*/
public static String getTestFilePath(String path) {
String junitRoot = System.getProperty("dir.source.root");
if (junitRoot == null) {
junitRoot = "";
}
return new File(junitRoot + TEST_FOLDER + path).getPath();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment