| Index: tools/testing/dart/test_suite.dart
|
| diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
|
| index 894fb5a6f5a6644b892859b9d941be804c665679..d360d0f61f13b117553cee59fc702ac411861e53 100644
|
| --- a/tools/testing/dart/test_suite.dart
|
| +++ b/tools/testing/dart/test_suite.dart
|
| @@ -23,9 +23,7 @@ import "multitest.dart";
|
| import "status_file_parser.dart";
|
| import "test_runner.dart";
|
| import "utils.dart";
|
| -
|
| -// TODO(efortuna,whess): Remove this import.
|
| -import 'vendored_pkg/path/path.dart' as pathLib;
|
| +import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR;
|
|
|
| part "browser_test.dart";
|
|
|
| @@ -812,7 +810,77 @@ class StandardTestSuite extends TestSuite {
|
| };
|
| }
|
|
|
| - /**
|
| +
|
| + /**
|
| + * _createUrlPathFromFile takes a [file], which is either located in the dart
|
| + * or in the build directory, and will return a String representing
|
| + * the relative path to either the dart or the build directory.
|
| + * Thus, the returned [String] will be the path component of the URL
|
| + * corresponding to [file] (the http server serves files relative to the
|
| + * dart/build directories).
|
| + */
|
| + String _createUrlPathFromFile(Path file) {
|
| + file = TestUtils.absolutePath(file);
|
| +
|
| + var relativeBuildDir = new Path(TestUtils.buildDir(configuration));
|
| + var buildDir = TestUtils.absolutePath(relativeBuildDir);
|
| + var dartDir = TestUtils.absolutePath(TestUtils.dartDir());
|
| +
|
| + var fileString = file.toString();
|
| + if (fileString.startsWith(buildDir.toString())) {
|
| + var fileRelativeToBuildDir = file.relativeTo(buildDir);
|
| + return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir";
|
| + } else if (fileString.startsWith(dartDir.toString())) {
|
| + var fileRelativeToDartDir = file.relativeTo(dartDir);
|
| + return "/$PREFIX_DARTDIR/$fileRelativeToDartDir";
|
| + }
|
| + // Unreachable
|
| + Except.fail('This should be unreachable.');
|
| + }
|
| +
|
| + void _getUriForBrowserTest(TestInformation info,
|
| + String pathComponent,
|
| + subtestNames,
|
| + subtestIndex) {
|
| + // Note: If we run test.py with the "--list" option, no http servers
|
| + // will be started. Therefore serverList is an empty list in this
|
| + // case. So we use PORT/CROSS_ORIGIN_PORT instead of real ports.
|
| + var serverPort = "PORT";
|
| + var crossOriginPort = "CROSS_ORIGIN_PORT";
|
| + if (!configuration['list']) {
|
| + serverPort = serverList[0].port.toString();
|
| + crossOriginPort = serverList[1].port.toString();
|
| + }
|
| +
|
| + var url= 'http://127.0.0.1:$serverPort$pathComponent'
|
| + '?crossOriginPort=$crossOriginPort';
|
| + if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) {
|
| + url= '${url}&group=${subtestNames[subtestIndex]}';
|
| + }
|
| + return url;
|
| + }
|
| +
|
| + void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) {
|
| + File file = new File(dartWrapperFilename);
|
| + RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE);
|
| +
|
| + var usePackageImport = dartLibraryFilename.segments().contains("pkg");
|
| + var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename);
|
| + dartWrapper.writeStringSync(dartTestWrapper(usePackageImport,
|
| + libraryPathComponent));
|
| + dartWrapper.closeSync();
|
| + }
|
| +
|
| + void _createLibraryWrapperFile(Path dartLibraryFilename, filePath) {
|
| + File file = new File(dartLibraryFilename.toNativePath());
|
| + RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE);
|
| + var requestPath = new Path(PREFIX_DARTDIR)
|
| + .join(filePath.relativeTo(TestUtils.dartDir()));
|
| + dartLibrary.writeStringSync(wrapDartTestInLibrary(requestPath));
|
| + dartLibrary.closeSync();
|
| + }
|
| +
|
| + /**
|
| * The [StandardTestSuite] has support for tests that
|
| * compile a test from Dart to JavaScript, and then run the resulting
|
| * JavaScript. This function creates a working directory to hold the
|
| @@ -867,18 +935,9 @@ class StandardTestSuite extends TestSuite {
|
| if (!isLibraryDefinition) {
|
| dartLibraryFilename = new Path(tempDir).append(
|
| 'test_as_library.dart');
|
| - File file = new File(dartLibraryFilename.toNativePath());
|
| - RandomAccessFile dartLibrary = file.openSync(FileMode.WRITE);
|
| - dartLibrary.writeStringSync(
|
| - wrapDartTestInLibrary(filePath, file.name));
|
| - dartLibrary.closeSync();
|
| + _createLibraryWrapperFile(dartLibraryFilename, filePath);
|
| }
|
| -
|
| - File file = new File(dartWrapperFilename);
|
| - RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE);
|
| - dartWrapper.writeStringSync(
|
| - dartTestWrapper(dartDir, file.name, dartLibraryFilename));
|
| - dartWrapper.closeSync();
|
| + _createWrapperFile(dartWrapperFilename, dartLibraryFilename);
|
| } else {
|
| dartWrapperFilename = filename;
|
| // TODO(whesse): Once test.py is retired, adjust the relative path in
|
| @@ -895,8 +954,10 @@ class StandardTestSuite extends TestSuite {
|
| }
|
| htmlPath = '$tempDir/../$htmlFilename';
|
| }
|
| - final String scriptPath = (compiler == 'none') ?
|
| + String scriptPath = (compiler == 'none') ?
|
| dartWrapperFilename : compiledDartWrapperFilename;
|
| + scriptPath = _createUrlPathFromFile(new Path(scriptPath));
|
| +
|
| // Create the HTML file for the test.
|
| RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE);
|
| String content = null;
|
| @@ -907,22 +968,13 @@ class StandardTestSuite extends TestSuite {
|
| Path expectedOutput = null;
|
| if (new File.fromPath(pngPath).existsSync()) {
|
| expectedOutput = pngPath;
|
| - // TODO(efortuna): Unify path libraries in test.dart.
|
| - content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath,
|
| - from: pathLib.dirname(htmlPath)));
|
| + content = getHtmlLayoutContents(scriptType, new Path("$scriptPath"));
|
| } else if (new File.fromPath(txtPath).existsSync()) {
|
| expectedOutput = txtPath;
|
| - content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath,
|
| - from: pathLib.dirname(htmlPath)));
|
| + content = getHtmlLayoutContents(scriptType, new Path("$scriptPath"));
|
| } else {
|
| - final htmlLocation = new Path(htmlPath);
|
| - content = getHtmlContents(
|
| - filename,
|
| - dartDir.append('pkg/unittest/lib/test_controller.js')
|
| - .relativeTo(htmlLocation),
|
| - dartDir.append('pkg/browser/lib/dart.js').relativeTo(htmlLocation),
|
| - scriptType,
|
| - new Path(scriptPath).relativeTo(htmlLocation));
|
| + content = getHtmlContents(filename, scriptType,
|
| + new Path("$scriptPath"));
|
| }
|
| htmlTest.writeStringSync(content);
|
| htmlTest.closeSync();
|
| @@ -962,35 +1014,11 @@ class StandardTestSuite extends TestSuite {
|
| commandSet = [];
|
| }
|
|
|
| - List<String> args = <String>[];
|
| - var basePath = TestUtils.dartDir().toString();
|
| - if (!htmlPath.startsWith('/') && !htmlPath.startsWith('http')) {
|
| - htmlPath = '/$htmlPath';
|
| - }
|
| - htmlPath = htmlPath.startsWith(basePath) ?
|
| - htmlPath.substring(basePath.length) : htmlPath;
|
| - String fullHtmlPath = htmlPath;
|
| - var searchStr = '?';
|
| - if (!htmlPath.startsWith('http')) {
|
| - // Note: If we run test.py with the "--list" option, no http servers
|
| - // will be started. Therefore serverList is an empty list in this
|
| - // case. So we use PORT/CROSS_ORIGIN_PORT instead of real ports.
|
| - var serverPort = "PORT";
|
| - var crossOriginPort = "CROSS_ORIGIN_PORT";
|
| - if (!configuration['list']) {
|
| - serverPort = serverList[0].port.toString();
|
| - crossOriginPort = serverList[1].port.toString();
|
| - }
|
| - fullHtmlPath = 'http://127.0.0.1:$serverPort$htmlPath${searchStr}'
|
| - 'crossOriginPort=$crossOriginPort';
|
| - searchStr = '&';
|
| - }
|
| - if (info.optionsFromFile['isMultiHtmlTest']
|
| - && subtestNames.length > 0) {
|
| - fullHtmlPath = '${fullHtmlPath}${searchStr}group='
|
| - '${subtestNames[subtestIndex]}';
|
| - }
|
| + var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath));
|
| + var fullHtmlPath = _getUriForBrowserTest(info, htmlPath_subtest,
|
| + subtestNames, subtestIndex);
|
|
|
| + List<String> args = <String>[];
|
| if (TestUtils.usesWebDriver(runtime)) {
|
| args = [
|
| dartDir.append('tools/testing/run_selenium.py').toNativePath(),
|
| @@ -1125,8 +1153,7 @@ class StandardTestSuite extends TestSuite {
|
| var minified = configuration['minified'] ? '-minified' : '';
|
| var dirName = "${configuration['compiler']}-${configuration['runtime']}"
|
| "$checked$minified";
|
| - Path generatedTestPath = new Path(dartDir.toNativePath())
|
| - .append(buildDir)
|
| + Path generatedTestPath = new Path(buildDir)
|
| .append('generated_tests')
|
| .append(dirName)
|
| .append(testUniqueName);
|
| @@ -1816,6 +1843,10 @@ class TestUtils {
|
| const ['d8', 'jsshell'].contains(runtime);
|
|
|
| static String buildDir(Map configuration) {
|
| + // FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir'
|
| + // is relative to the current working directory.
|
| + // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out')
|
| + // we get into trouble.
|
| if (configuration['build_directory'] != '') {
|
| return configuration['build_directory'];
|
| }
|
|
|