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 1a55c6c851cbe1a4035b53c54136df6628193301..f390ba040c2a9ea8fb5fdc994f17bb0b83da0eab 100644 |
| --- a/tools/testing/dart/test_suite.dart |
| +++ b/tools/testing/dart/test_suite.dart |
| @@ -17,6 +17,7 @@ library test_suite; |
| import "dart:async"; |
| import "dart:io"; |
| import "drt_updater.dart"; |
| +import "html_test.dart" as htmlTest; |
| import "multitest.dart"; |
| import "status_file_parser.dart"; |
| import "test_runner.dart"; |
| @@ -45,13 +46,13 @@ RegExp multiTestRegExp = new RegExp(r"\S *" |
| typedef bool Predicate<T>(T arg); |
| typedef void CreateTest(Path filePath, |
| + Path originTestPath, |
| bool hasCompileError, |
| bool hasRuntimeError, |
| {bool isNegativeIfChecked, |
| bool hasCompileErrorIfChecked, |
| bool hasStaticWarning, |
| - String multitestKey, |
| - Path originTestPath}); |
| + String multitestKey}); |
| typedef void VoidFunction(); |
| @@ -563,8 +564,8 @@ class CCTestSuite extends TestSuite { |
| class TestInformation { |
| - Path originTestPath; |
| Path filePath; |
| + Path originTestPath; |
| Map optionsFromFile; |
| bool hasCompileError; |
| bool hasRuntimeError; |
| @@ -573,16 +574,26 @@ class TestInformation { |
| bool hasStaticWarning; |
| String multitestKey; |
| - TestInformation(this.filePath, this.optionsFromFile, |
| + TestInformation(this.filePath, this.originTestPath, this.optionsFromFile, |
| this.hasCompileError, this.hasRuntimeError, |
| this.isNegativeIfChecked, this.hasCompileErrorIfChecked, |
| this.hasStaticWarning, |
| - {this.multitestKey, this.originTestPath}) { |
| + {this.multitestKey: ''}) { |
| assert(filePath.isAbsolute); |
| - if (originTestPath == null) originTestPath = filePath; |
| } |
| } |
| + |
| +class HtmlTestInformation extends TestInformation { |
| + List<String> expectedMessages; |
| + List<String> scripts; |
| + |
| + HtmlTestInformation(Path filePath, this.expectedMessages, this.scripts) |
| + : super(filePath, filePath, |
| + {'isMultitest': false, 'isMultiHtmlTest': false}, |
| + false, false, false, false, false) {} |
| +} |
| + |
|
ricow1
2014/11/04 09:18:03
two newlines
Bill Hesse
2014/11/04 16:29:01
Put two newlines between all classes in the file.
|
| /** |
| * A standard [TestSuite] implementation that searches for tests in a |
| * directory, and creates [TestCase]s that compile and/or run them. |
| @@ -671,10 +682,13 @@ class StandardTestSuite extends TestSuite { |
| bool isTestFile(String filename) { |
| // Use the specified predicate, if provided. |
| if (isTestFilePredicate != null) return isTestFilePredicate(filename); |
| - |
| - return filename.endsWith("Test.dart"); |
| + // TODO(whesse): Remove check, and make the default "_test.dart", if |
| + // this line is never hit. |
| + throw new Exception('This suite uses obsolete "Test.dart" filenames'); |
|
ricow1
2014/11/04 09:18:03
do this in a separate cl please
Bill Hesse
2014/11/04 16:29:01
Done.
|
| } |
| + bool isHtmlTestFile(String filename) => filename.endsWith('_htmltest.html'); |
| + |
| List<String> additionalOptions(Path filePath) => []; |
| Map<String, String> localPackageDirectories; |
| @@ -768,6 +782,16 @@ class StandardTestSuite extends TestSuite { |
| } |
| void enqueueFile(String filename, FutureGroup group) { |
| + if (isHtmlTestFile(filename)) { |
| + var info = htmlTest.getInformation(filename); |
| + if (info == null) { |
| + print("Invalid HtmlTest $filename"); |
|
ricow1
2014/11/04 09:18:03
so I don't think this will catch peoples attention
Bill Hesse
2014/11/04 16:29:01
This is rather hard to do. At this point, we woul
|
| + return; |
| + } |
| + cachedTests.add(info); |
| + enqueueTestCaseFromTestInformation(info); |
| + return; |
| + } |
| if (!isTestFile(filename)) return; |
| Path filePath = new Path(filename); |
| @@ -781,6 +805,7 @@ class StandardTestSuite extends TestSuite { |
| group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase)); |
| } else { |
| createTestCase(filePath, |
| + filePath, |
| optionsFromFile['hasCompileError'], |
| optionsFromFile['hasRuntimeError'], |
| hasStaticWarning: optionsFromFile['hasStaticWarning']); |
| @@ -809,6 +834,14 @@ class StandardTestSuite extends TestSuite { |
| } |
| void enqueueTestCaseFromTestInformation(TestInformation info) { |
| + String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, |
| + multitestName: info.multitestKey); |
| + Set<Expectation> expectations = testExpectations.expectations(testName); |
| + if (info is HtmlTestInformation && |
| + TestUtils.isBrowserRuntime(configuration['runtime'])) { |
| + enqueueBrowserTest([], null, info, testName, expectations); |
| + return; |
| + } |
| var filePath = info.filePath; |
| var optionsFromFile = info.optionsFromFile; |
| @@ -876,15 +909,15 @@ class StandardTestSuite extends TestSuite { |
| Path packageRoot; |
| if (configuration['use_repository_packages'] || |
| configuration['use_public_packages']) { |
| - Path pubspecYamlFile = _findPubspecYamlFile(filePath); |
| - if (pubspecYamlFile != null) { |
| - var result = buildSpecialPackageRoot(pubspecYamlFile); |
| - baseCommands.addAll(result['commands']); |
| - packageRoot = result['package-root']; |
| - if (optionsFromFile['packageRoot'] == null || |
| - optionsFromFile['packageRoot'] == "") { |
| - optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| - } |
| + Path pubspecYamlFile = _findPubspecYamlFile(filePath); |
| + if (pubspecYamlFile != null) { |
| + var result = buildSpecialPackageRoot(pubspecYamlFile); |
| + baseCommands.addAll(result['commands']); |
| + packageRoot = result['package-root']; |
| + if (optionsFromFile['packageRoot'] == null || |
| + optionsFromFile['packageRoot'] == "") { |
| + optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| + } |
| } |
| } |
| if (configuration['package_root'] != null) { |
| @@ -892,10 +925,6 @@ class StandardTestSuite extends TestSuite { |
| optionsFromFile['packageRoot'] = packageRoot.toNativePath(); |
| } |
| - String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, |
| - multitestName: optionsFromFile['isMultitest'] ? info.multitestKey : ""); |
| - |
| - Set<Expectation> expectations = testExpectations.expectations(testName); |
| if (new CompilerConfiguration(configuration).hasCompiler && |
| expectCompileError(info)) { |
| // If a compile-time error is expected, and we're testing a |
| @@ -1020,23 +1049,23 @@ class StandardTestSuite extends TestSuite { |
| CreateTest makeTestCaseCreator(Map optionsFromFile) { |
| return (Path filePath, |
| + Path originTestPath, |
| bool hasCompileError, |
| bool hasRuntimeError, |
| {bool isNegativeIfChecked: false, |
| bool hasCompileErrorIfChecked: false, |
| bool hasStaticWarning: false, |
| - String multitestKey, |
| - Path originTestPath}) { |
| + String multitestKey}) { |
| // Cache the test information for each test case. |
| var info = new TestInformation(filePath, |
| + originTestPath, |
| optionsFromFile, |
| hasCompileError, |
| hasRuntimeError, |
| isNegativeIfChecked, |
| hasCompileErrorIfChecked, |
| hasStaticWarning, |
| - multitestKey: multitestKey, |
| - originTestPath: originTestPath); |
| + multitestKey: multitestKey); |
| cachedTests.add(info); |
| enqueueTestCaseFromTestInformation(info); |
| }; |
| @@ -1134,6 +1163,33 @@ class StandardTestSuite extends TestSuite { |
| final String compiler = configuration['compiler']; |
| final String runtime = configuration['runtime']; |
| + if (info is HtmlTestInformation) { |
| + if (compiler != 'none' || runtime != 'dartium') { |
| + // TODO(whesse): Enable compilation of scripts to dart2js, and |
| + // rewriting of script links in html file. Currently unimplemented. |
| + return; |
| + } |
| + if (info.scripts.length > 0) { |
| + // TODO(whesse): Copy scripts into output directory. |
| + return; |
| + } |
| + final String tempDir = createOutputDirectory(info.filePath, ''); |
| + final String htmlFile = '$tempDir/${filePath.filename}'; |
| + new File(htmlFile).writeAsStringSync(htmlTest.getContents(info)); |
| + |
| + String testDisplayName = '$suiteName/$testName'; |
| + var htmlPath = _createUrlPathFromFile(new Path(htmlFile)); |
| + var fullHtmlPath = _getUriForBrowserTest(info, htmlPath, |
| + null, null); |
| + var commands = [CommandBuilder.instance.getBrowserHtmlTestCommand( |
| + runtime, fullHtmlPath, configuration, info.expectedMessages)]; |
| + var testCase = new BrowserTestCase(testDisplayName, |
| + commands, configuration, expectations, |
| + info, isNegative(info), fullHtmlPath); |
| + enqueueNewTestCase(testCase); |
| + return; |
| + } |
| + |
| for (var vmOptions in getVmOptions(optionsFromFile)) { |
| // Create a unique temporary directory for each set of vmOptions. |
| // TODO(dart:429): Replace separate replaceAlls with a RegExp when |