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

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

Issue 8889016: Enable Dartium tests in tools/test.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 9 years 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
« tools/testing/dart/test_runner.dart ('K') | « 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 e31be54dd9e2f6a81e5e88faba9e3da542447ca0..5249c62edcd079b08871f91835ddc23c12cc695c 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -8,6 +8,7 @@
#import("test_runner.dart");
#import("multitest.dart");
+#source("browser_test.dart");
interface TestSuite {
void forEachTest(Function onTest, [Function onDone]);
@@ -133,11 +134,13 @@ class StandardTestSuite implements TestSuite {
int activeTestGenerators = 0;
bool listingDone = false;
TestExpectations testExpectations;
+ final String pathSeparator;
StandardTestSuite(Map this.configuration,
String this.suiteName,
String this.directoryPath,
- List<String> this.statusFilePaths);
+ List<String> this.statusFilePaths)
+ : pathSeparator = new Platform().pathSeparator();
void isTestFile(String filename) => filename.endsWith("Test.dart");
@@ -171,7 +174,11 @@ class StandardTestSuite implements TestSuite {
dir.errorHandler = (s) {
throw s;
};
- dir.fileHandler = processFile;
+ if (configuration['component'] == 'dartium') {
+ dir.fileHandler = processDartiumFile;
+ } else {
+ dir.fileHandler = processFile;
+ }
dir.doneHandler = directoryListingDone;
dir.list(recursive: listRecursively());
}
@@ -182,7 +189,6 @@ class StandardTestSuite implements TestSuite {
[bool isNegativeIfChecked = false,
bool enableFatalTypeErrors = false]) {
// Look up expectations in status files using a modified file path.
- String pathSeparator = new Platform().pathSeparator();
String testName;
int start = filename.lastIndexOf('src' + pathSeparator);
if (start != -1) {
@@ -253,6 +259,121 @@ class StandardTestSuite implements TestSuite {
}
}
+ void processDartiumFile(String filename) {
+ if (!isTestFile(filename)) return;
+
+ // Only run the tests that match the pattern.
Mads Ager (google) 2011/12/09 13:19:37 I still think these line should be extracted into
+ RegExp pattern = configuration['selectors'][suiteName];
+ if (!pattern.hasMatch(filename)) return;
+
+ var optionsFromFile = optionsFromFile(filename);
+ if (optionsFromFile['isMultitest']) return;
+
+ String testName;
+ int start = filename.lastIndexOf('src' + pathSeparator);
+ if (start != -1) {
+ testName = filename.substring(start + 4, filename.length - 5);
+ } else {
+ // This case is hit by the dartc client compilation
+ // tests. These tests are pretty broken compared to the
+ // rest. They use the .dart suffix in the status files. They
+ // find tests in weird ways (testing that they contain "#").
+ // They need to be redone.
+ start = filename.indexOf(directoryPath);
+ testName = filename.substring(start + directoryPath.length + 1,
+ filename.length);
+ }
+ Set<String> expectations = testExpectations.expectations(testName);
+ if (expectations.contains(SKIP)) return;
+
+ var timeout = configuration['timeout'];
+ bool isWebTest = optionsFromFile['containsDomImport'];
+ bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
+ if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
+ print('Warning for $filename: Browser tests require #library ' +
+ 'in any file that uses #import or #source');
+ }
+
+ Directory tempDir = new Directory((isWebTest ? 'client/' : '') +
+ TestUtils.buildDir(configuration) +
+ 'tmp');
+ // TODO(whesse): Create directory in the client case, if it doesn't exist.
Mads Ager (google) 2011/12/09 13:19:37 I'm not sure I understand this TODO. If client doe
+ tempDir.createTempSync();
+
+ String dartTestFilename = new File(filename).fullPathSync();
+ String dartWrapperFilename = '${tempDir.path}/test.dart';
+ if (!isWebTest) {
+ // test.dart will import the dart test directly, if it is a library,
+ // or indirectly through test_as_library.dart, if it is not.
+ String dartLibraryFilename;
+ if (isLibraryDefinition) {
+ dartLibraryFilename = dartTestFilename;
+ } else {
+ dartLibraryFilename = 'test_as_library.dart';
+ File file = new File('${tempDir.path}/$dartLibraryFilename');
+ RandomAccessFile dartLibrary = file.openSync(writable: true);
+ dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename));
+ dartLibrary.closeSync();
+ }
+
+ File file = new File(dartWrapperFilename);
+ RandomAccessFile dartWrapper = file.openSync(writable: true);
+ dartWrapper.writeStringSync(dartTestWrapper(dartLibraryFilename));
+ dartWrapper.closeSync();
+ }
+
+ // Create the HTML file for the test.
+ File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
+ RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
+ htmlTest.writeStringSync(GetHtmlContents(
+ filename,
+ 'client/testing/unittest/test_controller.js',
+ scriptType,
+ dartWrapperFilename));
+ htmlTest.closeSync();
+
+ for (var vmOptions in optionsFromFile["vmOptions"]) {
+ var drtFlags = ['-no-timeout'];
+ var dartFlags = ['--enable_asserts', '--enable_type_checks'];
+ dartFlags.addAll(vmOptions);
+ drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}');
+ var args = drtFlags;
+ args.add(htmlTestBase.fullPathSync());
+
+ // Create BrowserTestCase and queue it.
+ var testCase = new BrowserTestCase(
+ testName,
+ '/bin/echo',
+ ['No compilation step for component dartium.'],
+ dumpRenderTreeFilename,
+ args,
+ configuration,
+ completeHandler,
+ expectations, optionsFromFile['isNegative']);
+ doTest(testCase);
+ }
+ }
+
+ static String dartTestWrapper(String library) {
+ return DartTestWrapper('', '', 'dart:dom',
+ '../../../tests/isolate/src/TestFramework.dart',
+ library);
+ }
+
+ static String get scriptType() => 'application/dart';
+
+ String getHtmlName(String filename) {
+ return filename.replaceAll(pathSeparator, '_') + 'dartium.html';
+ }
+
+ static String get dumpRenderTreeFilename() {
+ if (new Platform().operatingSystem() == 'macos') {
+ return 'client/tests/drt/.app/Contents/MacOS/DumpRenderTree';
+ }
+ return 'client/tests/drt/DumpRenderTree';
+ }
+
+
void testGeneratorStarted() {
++activeTestGenerators;
}
@@ -319,11 +440,18 @@ class StandardTestSuite implements TestSuite {
RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)");
RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true);
RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)");
-
+ RegExp domImportRegExp =
+ const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)",
+ multiLine: true);
+ RegExp libraryDefinitionRegExp =
+ const RegExp(@"^#library\(", multiLine: true);
+ RegExp sourceOrImportRegExp =
+ const RegExp(@"^#(source|import)\(", multiLine: true);
+
// Read the entire file into a byte buffer and transform it to a
// String. This will treat the file as ascii but the only parts
// we are interested in will be ascii in any case.
- RandomAccessFile file = (new File(filename)).openSync();
+ RandomAccessFile file = new File(filename).openSync();
List chars = new List(file.lengthSync());
var offset = 0;
while (offset != chars.length) {
@@ -365,13 +493,20 @@ class StandardTestSuite implements TestSuite {
bool containsLeadingHash = leadingHashRegExp.hasMatch(contents);
Match isolateMatch = isolateStubsRegExp.firstMatch(contents);
String isolateStubs = isolateMatch != null ? isolateMatch[1] : '';
+ bool containsDomImport = domImportRegExp.hasMatch(contents);
+ bool isLibraryDefinition = libraryDefinitionRegExp.hasMatch(contents);
+ bool containsSourceOrImport = sourceOrImportRegExp.hasMatch(contents);
+
return { "vmOptions": result,
"dartOptions": dartOptions,
"isNegative": isNegative,
"isMultitest": isMultitest,
"containsLeadingHash" : containsLeadingHash,
- "isolateStubs" : isolateStubs };
+ "isolateStubs" : isolateStubs,
+ "containsDomImport": containsDomImport,
+ "isLibraryDefinition": isLibraryDefinition,
+ "containsSourceOrImport": containsSourceOrImport };
}
}
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698