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

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: 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 b45d9b887aeb32ac6ff2dd63d6d9718a1f296a9d..363aa8fef498571e070dfa67d5aa6fbf196a52d3 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -4,10 +4,13 @@
#library("test_suite");
+//#source("libraries.dart");
Mads Ager (google) 2011/12/09 09:21:12 ?
+
#import("status_file_parser.dart");
#import("test_runner.dart");
#import("multitest.dart");
+#source("browser_test.dart");
interface TestSuite {
void forEachTest(Function onTest, [Function onDone]);
@@ -135,9 +138,9 @@ class StandardTestSuite implements TestSuite {
TestExpectations testExpectations;
StandardTestSuite(Map this.configuration,
- String this.suiteName,
- String this.directoryPath,
- List<String> this.statusFilePaths);
+ String this.suiteName,
Mads Ager (google) 2011/12/09 09:21:12 Indentation
+ String this.directoryPath,
+ List<String> this.statusFilePaths);
void isTestFile(String filename) => filename.endsWith("Test.dart");
@@ -229,6 +232,10 @@ class StandardTestSuite implements TestSuite {
}
void processFile(String filename) {
+ if (configuration['component'] == 'dartium') {
Mads Ager (google) 2011/12/09 09:21:12 Everything up to and including the parsing of opti
Bill Hesse 2011/12/09 12:33:29 Split is done at the directory lister. These initi
+ processDartiumFile(filename);
+ return;
+ }
if (!isTestFile(filename)) return;
// Only run the tests that match the pattern.
@@ -253,6 +260,120 @@ class StandardTestSuite implements TestSuite {
}
}
+ void processDartiumFile(String filename) {
+ if (!isTestFile(filename)) return;
+
+ // Only run the tests that match the pattern.
+ RegExp pattern = configuration['selectors'][suiteName];
+ if (!pattern.hasMatch(filename)) return;
+
+ var optionsFromFile = optionsFromFile(filename);
+ if (optionsFromFile['isMultitest']) return;
+
+ String pathSeparator = new Platform().pathSeparator();
Mads Ager (google) 2011/12/09 09:21:12 This block of stuff looks familiar. That looks lik
Bill Hesse 2011/12/09 12:33:29 Moved to final class member. On 2011/12/09 09:21:
+ 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;
+
+
Mads Ager (google) 2011/12/09 09:21:12 Remove extra blank line.
+ 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.
+ 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 dartLibrary = new File('${tempDir.path}/$dartLibraryFilename');
+ dartLibrary.openSync(writable: true);
+ dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename));
+ dartLibrary.closeSync();
+ }
+
+ File dartWrapper = new File(dartWrapperFilename);
+ dartWrapper.openSync(writable: true);
+ dartWrapper.writeStringSync(dartTestWrapper(dartLibraryFilename));
+ dartWrapper.closeSync();
+ }
+
+ // Create the HTML file for the test.
+ File htmlTest = new File('${tempDir.path}/${getHtmlName(filename)}');
+ htmlTest.openSync(writable: true);
+ htmlTest.writeStringSync(GetHtmlContents(
+ filename,
+ 'client/testing/unittest/test_controller.js',
+ scriptType,
+ dartWrapperFilename));
+ htmlTest.closeSync();
+
+ var drtFlags = ['-no-timeout'];
+ var dartFlags = ['--enable_asserts', '--enable_type_checks'];
+ if (optionsFromFile['dartOptions'] != null) {
+ dartFlags.addAll(optionsFromFile['dartOptions']);
+ }
+ drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}');
+ var args = drtFlags;
+ args.add(htmlTest.fullPathSync());
+
+ // Create CompilingTestCase and queue it.
+ var testCase = new CompilingTestCase(
+ testName,
+ '/bin/cp',
+ ['/tmp/dogfile', '/tmp/cowfile'],
+ dumpRenderTreePath,
+ 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';
+
+ static String getHtmlName(String filename) {
+ // TODO(whesse): Implement:
+ // os.path.relpath(self.test, self.root_path).replace(os.sep, '_') +
+ // 'dartium.html'
+ return filename.replaceAll('/', '_') + 'dartium.html';
Mads Ager (google) 2011/12/09 09:21:12 path separator instead of '/'
Bill Hesse 2011/12/09 12:33:29 Done.
+ }
+
+ static String get dumpRenderTreePath() => 'client/tests/drt/DumpRenderTree';
+
void testGeneratorStarted() {
++activeTestGenerators;
}
@@ -319,7 +440,14 @@ 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.
@@ -366,13 +494,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 };
}
}
@@ -466,6 +601,14 @@ class TestUtils {
return name;
}
+ static String dumpRenderTreeFileName(Map configuration) {
+ String name = 'client/tests/drt';
+ if (new Platform().operatingSystem() == 'macos') {
+ name += '.app/Contents/MacOS/DumpRenderTree';
+ }
+ return name;
+ }
+
static String buildDir(Map configuration) {
var buildDir = '';
var system = configuration['system'];
« 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