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

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

Issue 8995009: Implement chromium component. (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
« 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 6a6c2bc74ea7cf0f819dcf965d677d2d78eb566b..d68ef524046751d17b2530ec237aeb95ae4fb290 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -60,7 +60,7 @@ class CCTestSuite implements TestSuite {
String this.suiteName,
String runnerName,
List<String> this.statusFilePaths) {
- runnerPath = TestUtils.buildDir(configuration) + runnerName;
+ runnerPath = TestUtils.buildDir(configuration) + '/' + runnerName;
}
void complexStatusMatching() => false;
@@ -260,6 +260,12 @@ class StandardTestSuite implements TestSuite {
expectations, isNegative);
return;
}
+ if (configuration['component'] == 'chromium') {
+ enqueueChromiumTest(filename, testName, optionsFromFile,
+ expectations, isNegative);
+ return;
+ }
+
// Only dartc supports fatal type errors. Enable fatal type
// errors with a flag and treat tests that have fatal type
// errors as negative.
@@ -334,9 +340,9 @@ class StandardTestSuite implements TestSuite {
'in any file that uses #import or #source');
}
- Directory tempDir = new Directory((isWebTest ? 'client/' : '') +
- TestUtils.buildDir(configuration) +
- 'tmp');
+ String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp';
+ if (isWebTest) tempDirTemplate = 'client/' + tempDirTemplate;
+ Directory tempDir = new Directory(tempDirTemplate);
// TODO(whesse): When implementing client web tests,
// create directory in the client case, if it doesn't exist.
tempDir.createTempSync();
@@ -359,7 +365,10 @@ class StandardTestSuite implements TestSuite {
File file = new File(dartWrapperFilename);
RandomAccessFile dartWrapper = file.openSync(writable: true);
- dartWrapper.writeStringSync(dartTestWrapper(dartLibraryFilename));
+ dartWrapper.writeStringSync(DartTestWrapper(
+ 'dart:dom',
+ '../../../tests/isolate/src/TestFramework.dart',
+ dartLibraryFilename));
dartWrapper.closeSync();
} else {
return; // TODO(whesse): Implement client web tests on dartium.
@@ -369,12 +378,13 @@ class StandardTestSuite implements TestSuite {
RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
htmlTest.writeStringSync(GetHtmlContents(
filename,
- 'client/testing/unittest/test_controller.js',
+ '../../../client/testing/unittest/test_controller.js',
scriptType,
- dartWrapperFilename));
+ '../../../$dartWrapperFilename'));
htmlTest.closeSync();
for (var vmOptions in optionsFromFile["vmOptions"]) {
+ var compileCommand = getCompileCommand(vmOptions);
var drtFlags = ['-no-timeout'];
var dartFlags = ['--enable_asserts', '--enable_type_checks'];
dartFlags.addAll(vmOptions);
@@ -385,8 +395,8 @@ class StandardTestSuite implements TestSuite {
// Create BrowserTestCase and queue it.
var testCase = new BrowserTestCase(
testName,
- '/bin/echo',
- ['No compilation step for component dartium.'],
+ compileCommand['executable'],
+ compileCommand['args'],
dumpRenderTreeFilename,
args,
configuration,
@@ -396,25 +406,160 @@ class StandardTestSuite implements TestSuite {
}
}
- static String dartTestWrapper(String library) {
- return DartTestWrapper('', '', 'dart:dom',
- '../../../tests/isolate/src/TestFramework.dart',
- library);
+ void enqueueChromiumTest(String filename,
+ String testName,
+ Map optionsFromFile,
+ Set<String> expectations,
+ bool isNegative) {
+ if (optionsFromFile['isMultitest']) return;
+ 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');
+ }
+
+ String dartDir = new File('.').fullPathSync();
+ String buildDir = TestUtils.buildDir(configuration);
+ String testPath = new File(filename).fullPathSync();
+ String outputDirBase = '$dartDir/$buildDir/generated_tests/chromium';
+
+ Expect.isTrue(testPath.startsWith(dartDir));
+ String testRelativePath = testPath.substring(dartDir.length + 1);
+ String testNameBase;
+ String testRelativeDir;
+ String testRelativeDirFlattened;
+
+ int start = testRelativePath.lastIndexOf('src' + pathSeparator);
+ if (start != -1) {
+ Expect.isTrue(testRelativePath.endsWith('.dart'));
+ testNameBase =
+ testRelativePath.substring(start + 4, testRelativePath.length - 5);
+ testRelativeDir = testRelativePath.substring(0, start - 1);
Mads Ager (google) 2011/12/20 09:03:01 Two spaces after the '='. Remove one of them.
Bill Hesse 2011/12/21 15:33:43 Done.
+ testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_');
+ } else {
+ Expect.fail('Web tests not imlemented yet');
+ }
+
+ print('''
Mads Ager (google) 2011/12/20 09:03:01 Delete.
+ dartDir: $dartDir
+ buildDir: $buildDir
+ testPath: $testPath:
+ testRelativePath: $testRelativePath:
+ testNameBase: $testNameBase:
+ testRelativeDir: $testRelativeDir:
+ testRelativeDirFlattened: $testRelativeDirFlattened''');
+
+ if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) {
+ new Directory('$dartDir/$buildDir/generated_tests').createSync();
+ }
+ if (!new Directory(outputDirBase).existsSync()) {
+ new Directory(outputDirBase).createSync();
+ }
+ Directory tempDir = new Directory(
+ '$outputDirBase/${testRelativeDirFlattened}_$testNameBase');
+ if (!tempDir.existsSync()) {
+ tempDir.createSync();
+ }
+
+ String dartWrapperFilename = '${tempDir.path}/test.dart';
+ String compiledDartWrapperFilename = '${tempDir.path}/test.js';
+ 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 = testPath;
+ } else {
+ dartLibraryFilename = 'test_as_library.dart';
+ File file = new File('${tempDir.path}/$dartLibraryFilename');
+ RandomAccessFile dartLibrary = file.openSync(writable: true);
+ dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath));
+ dartLibrary.closeSync();
+ }
+
+ File file = new File(dartWrapperFilename);
+ RandomAccessFile dartWrapper = file.openSync(writable: true);
+ dartWrapper.writeStringSync(DartTestWrapper(
+ '../../../../../client/testing/unittest/dom_for_unittest.dart',
+ '../../../../../tests/isolate/src/TestFramework.dart',
+ dartLibraryFilename));
+ dartWrapper.closeSync();
+ } else {
+ return; // TODO(whesse): Implement client web tests on dartium.
+ }
+ // 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,
+ compiledDartWrapperFilename));
+ htmlTest.closeSync();
+
+ for (var vmOptions in optionsFromFile["vmOptions"]) {
+ String dartcExecutable = '$dartDir/$buildDir/compiler/bin/dartc';
Mads Ager (google) 2011/12/20 09:03:01 Use the TestUtils dartc compilation helper to get
Bill Hesse 2011/12/21 15:33:43 Done.
+ List<String> dartcArgs = ['--work', tempDir.path];
+ if (configuration['mode'] == 'release') {
+ dartcArgs.add('--optimize');
+ }
+ dartcArgs.addAll(vmOptions);
+ dartcArgs.add('--ignore-unrecognized-flags');
+ dartcArgs.add('--out');
+ dartcArgs.add(compiledDartWrapperFilename);
+ dartcArgs.add(dartWrapperFilename);
+ // TODO(whesse): Add --fatal-type-errors if needed.
+ var args = ['--no-timeout'];
+ args.add(htmlTestBase.fullPathSync());
+
+ // Create BrowserTestCase and queue it.
+ var testCase = new BrowserTestCase(
+ testName,
+ dartcExecutable,
+ dartcArgs,
+ dumpRenderTreeFilename,
+ args,
+ configuration,
+ completeHandler,
+ expectations, optionsFromFile['isNegative']);
Mads Ager (google) 2011/12/20 09:03:01 Move isNegative to a separate line.
Bill Hesse 2011/12/21 15:33:43 Done.
+ doTest(testCase);
+ }
}
- static String get scriptType() => 'application/dart';
+ String get scriptType() =>
+ {'dartium': 'application/dart',
Mads Ager (google) 2011/12/20 09:03:01 Creating a map every time and performing a lookup
Bill Hesse 2011/12/21 15:33:43 Done.
+ 'chromium': 'text/javascript'}[configuration['component']];
+
+ String get scriptName() => tempDir.path +
Mads Ager (google) 2011/12/20 09:03:01 Ditto.
+ {'chromium': 'test.js',
+ 'dartium': 'test.dart'}[configuration['component']];
String getHtmlName(String filename) {
return filename.replaceAll(pathSeparator, '_') + 'dartium.html';
}
- static String get dumpRenderTreeFilename() {
+ String get dumpRenderTreeFilename() {
if (new Platform().operatingSystem() == 'macos') {
return 'client/tests/drt/.app/Contents/MacOS/DumpRenderTree';
}
return 'client/tests/drt/DumpRenderTree';
}
+ // Returns a Map with keys 'executable' and 'args'.
Bill Hesse 2011/12/19 16:18:58 This function will be removed again.
+ Map getCompileCommand(List<String> vmOptions) {
+ switch (configuration['component']) {
+ case 'dartium':
+ return {'executable': '/bin/echo',
+ 'args': ['No compilation step for component dartium.']};
+ case 'chromium':
+ return {'executable': '/bin/echo',
+ 'args': ['Unimplemented compilation step for component chromium.']};
+ default:
+ return {'executable': '/bin/echo',
+ 'args': ['Unimplemented default case hit.']};
+ }
+ }
void testGeneratorStarted() {
++activeTestGenerators;
@@ -626,7 +771,7 @@ class TestUtils {
}
static String dartShellFileName(Map configuration) {
- var name = buildDir(configuration) + executableName(configuration);
+ var name = '${buildDir(configuration)}/${executableName(configuration)}';
if (!(new File(name)).existsSync()) {
throw "Executable '$name' does not exist";
}
@@ -634,7 +779,7 @@ class TestUtils {
}
static String dartcCompilationShellPath(Map configuration) {
- var name = buildDir(configuration) + 'compiler/bin/dartc';
+ var name = '${buildDir(configuration)}/compiler/bin/dartc';
if (!(new File(name)).existsSync()) {
throw "Executable '$name' does not exist";
}
@@ -655,7 +800,7 @@ class TestUtils {
static String buildDir(Map configuration) {
var buildDir = outputDir(configuration);
buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_';
- buildDir += configuration['arch'] + '/';
+ buildDir += configuration['arch'];
return buildDir;
}
« 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