Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: tools/testing/dart/test_suite.dart

Issue 695893002: Working SimpleHTML test front end (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0553fd095ac56998512f307f51acd4dfe8e1af0a 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) {}
+}
+
/**
* 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');
}
+ bool isHtmlTestFile(String filename) => filename.endsWith('_htmltest.html');
Bill Hesse 2014/11/03 09:21:09 I would like to use _test.html, but that is used b
+
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");
+ 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,28 @@ class StandardTestSuite extends TestSuite {
final String compiler = configuration['compiler'];
final String runtime = configuration['runtime'];
+ if (info is HtmlTestInformation) {
+ final String tempDir = createOutputDirectory(info.filePath, '');
+ final String htmlFile = '$tempDir/${filePath.filename}';
+ new File(htmlFile).writeAsStringSync(htmlTest.getContents(info));
+ print(htmlFile);
+ // Copy HTML file into tempDir
+ // Create BrowserTestCase (or subclass?)
+ // enqueue it
+ 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
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698