Chromium Code Reviews| Index: tools/testing/dart/test_suite.dart |
| diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart |
| index 53cc4f0b7c41d967e7b1c2f3432e457b9b4ef714..6c4650092a2f327b7fc73a9e4c36c4854e46aa96 100644 |
| --- a/tools/testing/dart/test_suite.dart |
| +++ b/tools/testing/dart/test_suite.dart |
| @@ -22,6 +22,7 @@ import "test_runner.dart"; |
| import "multitest.dart"; |
| import "drt_updater.dart"; |
| import "dart:uri"; |
| +import '../../../pkg/path/lib/path.dart' as pathLib; |
| part "browser_test.dart"; |
| @@ -408,11 +409,17 @@ class StandardTestSuite extends TestSuite { |
| final Path dartDir; |
| Predicate<String> isTestFilePredicate; |
| final bool listRecursively; |
| + /** |
| + * The set of servers that have been started to run these tests (Could be |
| + * none). |
| + */ |
| + List serverList; |
| StandardTestSuite(Map configuration, |
| String suiteName, |
| Path suiteDirectory, |
| this.statusFilePaths, |
| + this.serverList, |
|
ahe
2013/01/10 09:17:58
Why not use a named argument?
Emily Fortuna
2013/01/11 02:57:12
good idea. fixed.
|
| {this.isTestFilePredicate, |
| bool recursive: false}) |
| : super(configuration, suiteName), |
| @@ -446,14 +453,18 @@ class StandardTestSuite extends TestSuite { |
| * instead of having to create a custom [StandardTestSuite] subclass. In |
| * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] |
| * in test.dart, this will all be set up for you. |
| + * |
| + * The [StandardTestSuite] also optionally takes a list of servers that have |
| + * been started up by the test harness, to be used by browser tests. |
| */ |
| factory StandardTestSuite.forDirectory( |
| - Map configuration, Path directory) { |
| + Map configuration, Path directory, [List serverList = const []]) { |
| final name = directory.filename; |
| return new StandardTestSuite(configuration, |
| name, directory, |
| ['$directory/$name.status', '$directory/${name}_dart2js.status'], |
| + serverList, |
| isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), |
| recursive: true); |
| } |
| @@ -860,7 +871,7 @@ class StandardTestSuite extends TestSuite { |
| File file = new File(dartWrapperFilename); |
| RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); |
| dartWrapper.writeStringSync( |
| - dartTestWrapper(dartDir, dartLibraryFilename)); |
| + dartTestWrapper(dartDir, file.name, dartLibraryFilename)); |
| dartWrapper.closeSync(); |
| } else { |
| dartWrapperFilename = filename; |
| @@ -882,12 +893,6 @@ class StandardTestSuite extends TestSuite { |
| dartWrapperFilename : compiledDartWrapperFilename; |
| // Create the HTML file for the test. |
| RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); |
| - String filePrefix = ''; |
| - if (Platform.operatingSystem == 'windows') { |
| - // Firefox on Windows does not like absolute file path names that start |
| - // with 'C:' adding 'file:///' solves the problem. |
| - filePrefix = 'file:///'; |
| - } |
| String content = null; |
| Path dir = filePath.directoryPath; |
| String nameNoExt = filePath.filenameWithoutExtension; |
| @@ -896,10 +901,12 @@ class StandardTestSuite extends TestSuite { |
| Path expectedOutput = null; |
| if (new File.fromPath(pngPath).existsSync()) { |
| expectedOutput = pngPath; |
| - content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); |
| + content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, |
| + from: pathLib.dirname(htmlPath))); |
| } else if (new File.fromPath(txtPath).existsSync()) { |
| expectedOutput = txtPath; |
| - content = getHtmlLayoutContents(scriptType, '$filePrefix$scriptPath'); |
| + content = getHtmlLayoutContents(scriptType, pathLib.relative(scriptPath, |
| + from: pathLib.dirname(htmlPath))); |
| } else { |
| final htmlLocation = new Path.fromNative(htmlPath); |
| content = getHtmlContents( |
| @@ -949,10 +956,17 @@ class StandardTestSuite extends TestSuite { |
| } |
| List<String> args = <String>[]; |
| - String fullHtmlPath = htmlPath.startsWith('http:') ? htmlPath : |
| - (htmlPath.startsWith('/') ? |
| - 'file://$htmlPath' : |
| - 'file:///$htmlPath'); |
| + 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; |
| + if (!htmlPath.startsWith('http')) { |
| + fullHtmlPath = 'http://127.0.0.1:${serverList[0].port}$htmlPath?' |
| + 'crossOriginPort=${serverList[1].port}'; |
| + } |
| if (info.optionsFromFile['isMultiHtmlTest'] |
| && subtestNames.length > 0) { |
| fullHtmlPath = '${fullHtmlPath}#${subtestNames[subtestIndex]}'; |
| @@ -976,7 +990,6 @@ class StandardTestSuite extends TestSuite { |
| var dartFlags = []; |
| var dumpRenderTreeOptions = []; |
| - var packageRootUri; |
| dumpRenderTreeOptions.add('--no-timeout'); |
| @@ -988,16 +1001,6 @@ class StandardTestSuite extends TestSuite { |
| } |
| dartFlags.addAll(vmOptions); |
| } |
| - if (compiler == 'none') { |
| - var packageRootPath = packageRoot(optionsFromFile['packageRoot']); |
| - if (packageRootPath != null) { |
| - var absolutePath = |
| - TestUtils.absolutePath(new Path(packageRootPath)); |
| - packageRootUri = new Uri.fromComponents( |
| - scheme: 'file', |
| - path: absolutePath.toString()); |
| - } |
| - } |
| if (expectedOutput != null) { |
| if (expectedOutput.toNativePath().endsWith('.png')) { |
| @@ -1010,7 +1013,6 @@ class StandardTestSuite extends TestSuite { |
| fullHtmlPath, |
| dumpRenderTreeOptions, |
| dartFlags, |
| - packageRootUri, |
| expectedOutput)); |
| } |
| @@ -1104,7 +1106,8 @@ class StandardTestSuite extends TestSuite { |
| var minified = configuration['minified'] ? '-minified' : ''; |
| var dirName = "${configuration['compiler']}-${configuration['runtime']}" |
| "$checked$minified"; |
| - Path generatedTestPath = new Path.fromNative(buildDir) |
| + Path generatedTestPath = new Path.fromNative(dartDir.toString()) |
| + .append(buildDir.toString()) |
| .append('generated_tests') |
| .append(dirName) |
| .append(testUniqueName); |
| @@ -1445,7 +1448,8 @@ class DartcCompilationTestSuite extends StandardTestSuite { |
| : super(configuration, |
| suiteName, |
| new Path.fromNative(directoryPath), |
| - expectations); |
| + expectations, |
| + []); |
| List<String> additionalOptions(Path filePath) { |
| return ['--fatal-warnings', '--fatal-type-errors']; |
| @@ -1756,9 +1760,30 @@ class TestUtils { |
| } |
| static String configurationDir(Map configuration) { |
| + // For regular dart checkouts, the configDir by default is mode+arch. |
| + // For Dartium, the configDir by default is mode (as defined by the Chrome |
| + // build setup). We can detect this because in the dartium checkout, the |
| + // "output" directory is a sibling of the dart directory instead of a child. |
| var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release'; |
| var arch = configuration['arch'].toUpperCase(); |
| - return '$mode$arch'; |
| + if (currentWorkingDirectory != dartDir()) { |
| + return '$mode$arch'; |
| + } else { |
| + return mode; |
| + } |
| + } |
| + |
| + /** |
| + * Returns the path to the dart binary checked into the repo, used for |
| + * bootstrapping test.dart. |
| + */ |
| + static String get dartTestExecutable { |
| + var path = '${TestUtils.dartDir()}/tools/testing/bin/' |
| + '${Platform.operatingSystem}/dart'; |
| + if (Platform.operatingSystem == 'windows') { |
| + path.append('.exe'); |
| + } |
| + return path; |
|
kustermann
2013/01/10 09:05:42
We should really use the Path class everywhere we
|
| } |
| } |