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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 10809069: dart2dart compiler support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Next iteration Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | utils/tests/pub/pub.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Classes and methods for enumerating and preparing tests. 6 * Classes and methods for enumerating and preparing tests.
7 * 7 *
8 * This library includes: 8 * This library includes:
9 * 9 *
10 * - Creating tests by listing all the Dart files in certain directories, 10 * - Creating tests by listing all the Dart files in certain directories,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * test in the suite. When all tests have been processed, call [onDone]. 44 * test in the suite. When all tests have been processed, call [onDone].
45 * 45 *
46 * The [testCache] argument provides a persistent store that can be used to 46 * The [testCache] argument provides a persistent store that can be used to
47 * cache information about the test suite, so that directories do not need 47 * cache information about the test suite, so that directories do not need
48 * to be listed each time. 48 * to be listed each time.
49 */ 49 */
50 void forEachTest(Function onTest, Map testCache, [Function onDone]); 50 void forEachTest(Function onTest, Map testCache, [Function onDone]);
51 } 51 }
52 52
53 53
54 // TODO(1030): remove once in the corelib.
55 bool Contains(element, collection) => collection.indexOf(element) >= 0;
56
57
54 class CCTestListerIsolate extends Isolate { 58 class CCTestListerIsolate extends Isolate {
55 CCTestListerIsolate() : super.heavy(); 59 CCTestListerIsolate() : super.heavy();
56 60
57 void main() { 61 void main() {
58 port.receive((String runnerPath, SendPort replyTo) { 62 port.receive((String runnerPath, SendPort replyTo) {
59 var p = Process.start(runnerPath, ["--list"]); 63 var p = Process.start(runnerPath, ["--list"]);
60 StringInputStream stdoutStream = new StringInputStream(p.stdout); 64 StringInputStream stdoutStream = new StringInputStream(p.stdout);
61 List<String> tests = new List<String>(); 65 List<String> tests = new List<String>();
62 stdoutStream.onLine = () { 66 stdoutStream.onLine = () {
63 String line = stdoutStream.readLine(); 67 String line = stdoutStream.readLine();
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 makeCommands(info, args), 430 makeCommands(info, args),
427 configuration, 431 configuration,
428 completeHandler, 432 completeHandler,
429 expectations, 433 expectations,
430 isNegative, 434 isNegative,
431 info)); 435 info));
432 } 436 }
433 } 437 }
434 438
435 List<Command> makeCommands(TestInformation info, var args) { 439 List<Command> makeCommands(TestInformation info, var args) {
436 if (configuration['compiler'] == 'dart2js') { 440 switch (configuration['compiler']) {
441 case 'dart2js':
437 args = new List.from(args); 442 args = new List.from(args);
438 String tempDir = createOutputDirectory(info.filePath, ''); 443 String tempDir = createOutputDirectory(info.filePath, '');
439 args.add('--out=$tempDir/out.js'); 444 args.add('--out=$tempDir/out.js');
440 List<Command> commands = <Command>[new Command(shellPath(), args)]; 445 List<Command> commands = <Command>[new Command(shellPath(), args)];
441 if (configuration['runtime'] == 'd8') { 446 if (configuration['runtime'] == 'd8') {
442 var d8 = TestUtils.d8FileName(configuration); 447 var d8 = TestUtils.d8FileName(configuration);
443 commands.add(new Command(d8, ['$tempDir/out.js'])); 448 commands.add(new Command(d8, ['$tempDir/out.js']));
444 } 449 }
445 return commands; 450 return commands;
446 } else { 451
452 case 'dart2dart':
453 args = new List.from(args);
454 args.add('--output-type=dart');
455 String tempDir = createOutputDirectory(info.filePath, '');
456 args.add('--out=$tempDir/out.dart');
457 List<Command> commands = <Command>[new Command(shellPath(), args)];
458 if (configuration['runtime'] == 'vm') {
459 // TODO(antonm): support checked.
460 commands.add(new Command(
461 TestUtils.vmFileName(configuration),
462 ['--enable_checked_mode', '$tempDir/out.dart']));
463 } else {
464 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart';
465 }
466 return commands;
467
468 default:
447 return <Command>[new Command(shellPath(), args)]; 469 return <Command>[new Command(shellPath(), args)];
448 } 470 }
449 } 471 }
450 472
451 Function makeTestCaseCreator(Map optionsFromFile) { 473 Function makeTestCaseCreator(Map optionsFromFile) {
452 return (Path filePath, 474 return (Path filePath,
453 bool isNegative, 475 bool isNegative,
454 [bool isNegativeIfChecked = false, 476 [bool isNegativeIfChecked = false,
455 bool hasFatalTypeErrors = false, 477 bool hasFatalTypeErrors = false,
456 bool hasRuntimeErrors = false, 478 bool hasRuntimeErrors = false,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 '--out=$htmlPath']; 654 '--out=$htmlPath'];
633 if (runtime == 'dartium') { 655 if (runtime == 'dartium') {
634 args.add('--executable=$dartiumFilename'); 656 args.add('--executable=$dartiumFilename');
635 } 657 }
636 } else { 658 } else {
637 args = [ 659 args = [
638 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(), 660 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(),
639 dumpRenderTreeFilename, 661 dumpRenderTreeFilename,
640 '--no-timeout' 662 '--no-timeout'
641 ]; 663 ];
642 if (runtime == 'drt' && compiler == 'none') { 664 if (runtime == 'drt' &&
665 (compiler == 'none' || compiler == 'dart2dart')) {
643 var dartFlags = ['--ignore-unrecognized-flags']; 666 var dartFlags = ['--ignore-unrecognized-flags'];
644 if (configuration["checked"]) { 667 if (configuration["checked"]) {
645 dartFlags.add('--enable_asserts'); 668 dartFlags.add('--enable_asserts');
646 dartFlags.add("--enable_type_checks"); 669 dartFlags.add("--enable_type_checks");
647 } 670 }
648 dartFlags.addAll(vmOptions); 671 dartFlags.addAll(vmOptions);
649 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 672 args.add('--dart-flags=${Strings.join(dartFlags, " ")}');
650 } 673 }
651 args.add(htmlPath); 674 args.add(htmlPath);
652 if (expectedOutput != null) { 675 if (expectedOutput != null) {
(...skipping 21 matching lines...) Expand all
674 if (libdir == '') { 697 if (libdir == '') {
675 libdir = dartDir.append('frog/lib').toNativePath(); 698 libdir = dartDir.append('frog/lib').toNativePath();
676 } 699 }
677 args.addAll(['--libdir=$libdir', 700 args.addAll(['--libdir=$libdir',
678 '--compile-only', 701 '--compile-only',
679 '--out=$outputFile']); 702 '--out=$outputFile']);
680 args.addAll(vmOptions); 703 args.addAll(vmOptions);
681 args.add(inputFile); 704 args.add(inputFile);
682 break; 705 break;
683 case 'dart2js': 706 case 'dart2js':
707 case 'dart2dart':
708 if (compiler == 'dart2dart') args.add('--out=$outputFile');
684 args.add('--out=$outputFile'); 709 args.add('--out=$outputFile');
685 args.add(inputFile); 710 args.add(inputFile);
686 break; 711 break;
687 default: 712 default:
688 Expect.fail('unimplemented compiler $compiler'); 713 Expect.fail('unimplemented compiler $compiler');
689 } 714 }
690 if (executable.endsWith('.dart')) { 715 if (executable.endsWith('.dart')) {
691 // Run the compiler script via the Dart VM. 716 // Run the compiler script via the Dart VM.
692 args.insertRange(0, 1, executable); 717 args.insertRange(0, 1, executable);
693 executable = TestUtils.dartShellFileName(configuration); 718 executable = TestUtils.dartShellFileName(configuration);
(...skipping 30 matching lines...) Expand all
724 "${configuration['compiler']}-${configuration['runtime']}", 749 "${configuration['compiler']}-${configuration['runtime']}",
725 testUniqueName], '/'); 750 testUniqueName], '/');
726 751
727 TestUtils.mkdirRecursive(new Path('.'), new Path(generatedTestPath)); 752 TestUtils.mkdirRecursive(new Path('.'), new Path(generatedTestPath));
728 return new File(generatedTestPath).fullPathSync().replaceAll('\\', '/'); 753 return new File(generatedTestPath).fullPathSync().replaceAll('\\', '/');
729 } 754 }
730 755
731 String get scriptType() { 756 String get scriptType() {
732 switch (configuration['compiler']) { 757 switch (configuration['compiler']) {
733 case 'none': 758 case 'none':
759 case 'dart2dart':
734 return 'application/dart'; 760 return 'application/dart';
735 case 'frog': 761 case 'frog':
736 case 'dart2js': 762 case 'dart2js':
737 case 'dartc': 763 case 'dartc':
738 return 'text/javascript'; 764 return 'text/javascript';
739 default: 765 default:
740 Expect.fail('Non-web runtime, so no scriptType for: ' 766 Expect.fail('Non-web runtime, so no scriptType for: '
741 '${configuration["compiler"]}'); 767 '${configuration["compiler"]}');
742 return null; 768 return null;
743 } 769 }
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1252 }
1227 1253
1228 static String executableName(Map configuration) { 1254 static String executableName(Map configuration) {
1229 String suffix = executableSuffix(configuration['compiler']); 1255 String suffix = executableSuffix(configuration['compiler']);
1230 switch (configuration['compiler']) { 1256 switch (configuration['compiler']) {
1231 case 'none': 1257 case 'none':
1232 return 'dart$suffix'; 1258 return 'dart$suffix';
1233 case 'dartc': 1259 case 'dartc':
1234 return 'analyzer/bin/dart_analyzer$suffix'; 1260 return 'analyzer/bin/dart_analyzer$suffix';
1235 case 'dart2js': 1261 case 'dart2js':
1262 case 'dart2dart':
1236 var prefix = ''; 1263 var prefix = '';
1237 if (configuration['use_sdk']) { 1264 if (configuration['use_sdk']) {
1238 prefix = 'dart-sdk/bin/'; 1265 prefix = 'dart-sdk/bin/';
1239 } 1266 }
1240 if (configuration['host_checked']) { 1267 if (configuration['host_checked']) {
1241 // The script dart2js_developer is not in the SDK. 1268 // The script dart2js_developer is not in the SDK.
1242 return 'dart2js_developer$suffix'; 1269 return 'dart2js_developer$suffix';
1243 } else { 1270 } else {
1244 return '${prefix}dart2js$suffix'; 1271 return '${prefix}dart2js$suffix';
1245 } 1272 }
1246 case 'frog': 1273 case 'frog':
1247 return 'frog/bin/frog$suffix'; 1274 return 'frog/bin/frog$suffix';
1248 default: 1275 default:
1249 throw "Unknown executable for: ${configuration['compiler']}"; 1276 throw "Unknown executable for: ${configuration['compiler']}";
1250 } 1277 }
1251 } 1278 }
1252 1279
1253 static String compilerName(Map configuration) { 1280 static String compilerName(Map configuration) {
1254 String suffix = executableSuffix(configuration['compiler']); 1281 String suffix = executableSuffix(configuration['compiler']);
1255 switch (configuration['compiler']) { 1282 switch (configuration['compiler']) {
1256 case 'dartc': 1283 case 'dartc':
1257 case 'dart2js': 1284 case 'dart2js':
1285 case 'dart2dart':
1258 return executableName(configuration); 1286 return executableName(configuration);
1259 case 'frog': 1287 case 'frog':
1260 return 'frog/bin/frog$suffix'; 1288 return 'frog/bin/frog$suffix';
1261 default: 1289 default:
1262 throw "Unknown compiler for: ${configuration['compiler']}"; 1290 throw "Unknown compiler for: ${configuration['compiler']}";
1263 } 1291 }
1264 } 1292 }
1265 1293
1266 static String dartShellFileName(Map configuration) { 1294 static String dartShellFileName(Map configuration) {
1267 var name = configuration['dart']; 1295 var name = configuration['dart'];
1268 if (name == '') { 1296 if (name == '') {
1269 name = '${buildDir(configuration)}/${executableName(configuration)}'; 1297 name = '${buildDir(configuration)}/${executableName(configuration)}';
1270 } 1298 }
1271 ensureExists(name, configuration); 1299 ensureExists(name, configuration);
1272 return name; 1300 return name;
1273 } 1301 }
1274 1302
1275 static String d8FileName(Map configuration) { 1303 static String d8FileName(Map configuration) {
1276 var suffix = executableSuffix('d8'); 1304 var suffix = executableSuffix('d8');
1277 var d8 = '${buildDir(configuration)}/d8$suffix'; 1305 var d8 = '${buildDir(configuration)}/d8$suffix';
1278 ensureExists(d8, configuration); 1306 ensureExists(d8, configuration);
1279 return d8; 1307 return d8;
1280 } 1308 }
1281 1309
1310 static String vmFileName(Map configuration) {
1311 var suffix = executableSuffix('vm');
1312 var vm = '${buildDir(configuration)}/dart$suffix';
1313 ensureExists(vm, configuration);
1314 return vm;
1315 }
1316
1282 static void ensureExists(String filename, Map configuration) { 1317 static void ensureExists(String filename, Map configuration) {
1283 if (!configuration['list'] && !(new File(filename).existsSync())) { 1318 if (!configuration['list'] && !(new File(filename).existsSync())) {
1284 throw "Executable '$filename' does not exist"; 1319 throw "Executable '$filename' does not exist";
1285 } 1320 }
1286 } 1321 }
1287 1322
1288 static String compilerPath(Map configuration) { 1323 static String compilerPath(Map configuration) {
1289 if (configuration['compiler'] == 'none') { 1324 if (configuration['compiler'] == 'none') {
1290 return null; // No separate compiler for dartium tests. 1325 return null; // No separate compiler for dartium tests.
1291 } 1326 }
(...skipping 29 matching lines...) Expand all
1321 Path scriptPath = new Path.fromNative(scriptFile.fullPathSync()); 1356 Path scriptPath = new Path.fromNative(scriptFile.fullPathSync());
1322 return scriptPath.directoryPath.directoryPath; 1357 return scriptPath.directoryPath.directoryPath;
1323 } 1358 }
1324 1359
1325 static List<String> standardOptions(Map configuration) { 1360 static List<String> standardOptions(Map configuration) {
1326 List args = ["--ignore-unrecognized-flags"]; 1361 List args = ["--ignore-unrecognized-flags"];
1327 if (configuration["checked"]) { 1362 if (configuration["checked"]) {
1328 args.add('--enable_asserts'); 1363 args.add('--enable_asserts');
1329 args.add("--enable_type_checks"); 1364 args.add("--enable_type_checks");
1330 } 1365 }
1331 if (configuration["compiler"] == "dart2js") { 1366 String compiler = configuration["compiler"];
1367 if (compiler == "dart2js" || compiler == "dart2dart") {
1332 args = []; 1368 args = [];
1333 if (configuration["checked"]) { 1369 if (configuration["checked"]) {
1334 args.add('--enable-checked-mode'); 1370 args.add('--enable-checked-mode');
1335 } 1371 }
1336 args.add("--verbose"); 1372 // args.add("--verbose");
1337 if (!isBrowserRuntime(configuration['runtime'])) { 1373 if (!isBrowserRuntime(configuration['runtime'])) {
1338 args.add("--allow-mock-compilation"); 1374 args.add("--allow-mock-compilation");
1339 } 1375 }
1340 } 1376 }
1341 return args; 1377 return args;
1342 } 1378 }
1343 1379
1344 static bool isBrowserRuntime(String runtime) => 1380 static bool isBrowserRuntime(String runtime) => Contains(
1381 runtime,
1345 const <String>['drt', 1382 const <String>['drt',
1346 'dartium', 1383 'dartium',
1347 'ie', 1384 'ie',
1348 'safari', 1385 'safari',
1349 'opera', 1386 'opera',
1350 'chrome', 1387 'chrome',
1351 'ff'].indexOf(runtime) != -1; 1388 'ff']);
1352 } 1389 }
1353 1390
1354 class SummaryReport { 1391 class SummaryReport {
1355 static int total = 0; 1392 static int total = 0;
1356 static int skipped = 0; 1393 static int skipped = 0;
1357 static int noCrash = 0; 1394 static int noCrash = 0;
1358 static int pass = 0; 1395 static int pass = 0;
1359 static int failOk = 0; 1396 static int failOk = 0;
1360 static int fail = 0; 1397 static int fail = 0;
1361 static int crash = 0; 1398 static int crash = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 * $noCrash tests are expected to be flaky but not crash 1432 * $noCrash tests are expected to be flaky but not crash
1396 * $pass tests are expected to pass 1433 * $pass tests are expected to pass
1397 * $failOk tests are expected to fail that we won't fix 1434 * $failOk tests are expected to fail that we won't fix
1398 * $fail tests are expected to fail that we should fix 1435 * $fail tests are expected to fail that we should fix
1399 * $crash tests are expected to crash that we should fix 1436 * $crash tests are expected to crash that we should fix
1400 * $timeout tests are allowed to timeout 1437 * $timeout tests are allowed to timeout
1401 """; 1438 """;
1402 print(report); 1439 print(report);
1403 } 1440 }
1404 } 1441 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | utils/tests/pub/pub.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698