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

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: Created 8 years, 4 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
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 makeCommands(info, args), 426 makeCommands(info, args),
427 configuration, 427 configuration,
428 completeHandler, 428 completeHandler,
429 expectations, 429 expectations,
430 isNegative, 430 isNegative,
431 info)); 431 info));
432 } 432 }
433 } 433 }
434 434
435 List<Command> makeCommands(TestInformation info, var args) { 435 List<Command> makeCommands(TestInformation info, var args) {
436 if (configuration['compiler'] == 'dart2js') { 436 switch (configuration['compiler']) {
437 case 'dart2js':
437 args = new List.from(args); 438 args = new List.from(args);
438 String tempDir = createOutputDirectory(info.filePath, ''); 439 String tempDir = createOutputDirectory(info.filePath, '');
439 args.add('--out=$tempDir/out.js'); 440 args.add('--out=$tempDir/out.js');
440 List<Command> commands = <Command>[new Command(shellPath(), args)]; 441 List<Command> commands = <Command>[new Command(shellPath(), args)];
441 if (configuration['runtime'] == 'd8') { 442 if (configuration['runtime'] == 'd8') {
442 var d8 = TestUtils.d8FileName(configuration); 443 var d8 = TestUtils.d8FileName(configuration);
443 commands.add(new Command(d8, ['$tempDir/out.js'])); 444 commands.add(new Command(d8, ['$tempDir/out.js']));
444 } 445 }
445 return commands; 446 return commands;
446 } else { 447
448 case 'dart2dart':
449 args = new List.from(args);
450 args.add('--output-type=dart');
451 String tempDir = createOutputDirectory(info.filePath, '');
452 args.add('--out=$tempDir/out.dart');
453 List<Command> commands = <Command>[new Command(shellPath(), args)];
454 if (configuration['runtime'] == 'vm') {
455 // TODO(antonm): support checked.
456 commands.add(new Command(
457 TestUtils.vmFileName(configuration),
458 ['--enable_checked_mode', '$tempDir/out.dart']));
459 } else {
460 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart';
461 }
462 return commands;
463
464 default:
447 return <Command>[new Command(shellPath(), args)]; 465 return <Command>[new Command(shellPath(), args)];
448 } 466 }
449 } 467 }
450 468
451 Function makeTestCaseCreator(Map optionsFromFile) { 469 Function makeTestCaseCreator(Map optionsFromFile) {
452 return (Path filePath, 470 return (Path filePath,
453 bool isNegative, 471 bool isNegative,
454 [bool isNegativeIfChecked = false, 472 [bool isNegativeIfChecked = false,
455 bool hasFatalTypeErrors = false, 473 bool hasFatalTypeErrors = false,
456 bool hasRuntimeErrors = false, 474 bool hasRuntimeErrors = false,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 '--out=$htmlPath']; 650 '--out=$htmlPath'];
633 if (runtime == 'dartium') { 651 if (runtime == 'dartium') {
634 args.add('--executable=$dartiumFilename'); 652 args.add('--executable=$dartiumFilename');
635 } 653 }
636 } else { 654 } else {
637 args = [ 655 args = [
638 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(), 656 dartDir.append('tools/testing/drt-trampoline.py').toNativePath(),
639 dumpRenderTreeFilename, 657 dumpRenderTreeFilename,
640 '--no-timeout' 658 '--no-timeout'
641 ]; 659 ];
642 if (runtime == 'drt' && compiler == 'none') { 660 if (runtime == 'drt' &&
661 (compiler == 'none' || compiler == 'dart2dart')) {
643 var dartFlags = ['--ignore-unrecognized-flags']; 662 var dartFlags = ['--ignore-unrecognized-flags'];
644 if (configuration["checked"]) { 663 if (configuration["checked"]) {
645 dartFlags.add('--enable_asserts'); 664 dartFlags.add('--enable_asserts');
646 dartFlags.add("--enable_type_checks"); 665 dartFlags.add("--enable_type_checks");
647 } 666 }
648 dartFlags.addAll(vmOptions); 667 dartFlags.addAll(vmOptions);
649 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 668 args.add('--dart-flags=${Strings.join(dartFlags, " ")}');
650 } 669 }
651 args.add(htmlPath); 670 args.add(htmlPath);
652 if (expectedOutput != null) { 671 if (expectedOutput != null) {
(...skipping 24 matching lines...) Expand all
677 args.addAll(['--libdir=$libdir', 696 args.addAll(['--libdir=$libdir',
678 '--compile-only', 697 '--compile-only',
679 '--out=$outputFile']); 698 '--out=$outputFile']);
680 args.addAll(vmOptions); 699 args.addAll(vmOptions);
681 args.add(inputFile); 700 args.add(inputFile);
682 break; 701 break;
683 case 'dart2js': 702 case 'dart2js':
684 args.add('--out=$outputFile'); 703 args.add('--out=$outputFile');
685 args.add(inputFile); 704 args.add(inputFile);
686 break; 705 break;
706 case 'dart2dart':
707 args.add('--output-type=dart --out=$outputFile');
Bill Hesse 2012/07/24 11:58:59 This should be args.addAll(['--output-type=dart',
Anton Muhin 2012/07/25 11:19:57 Done.
708 args.add(inputFile);
709 break;
687 default: 710 default:
688 Expect.fail('unimplemented compiler $compiler'); 711 Expect.fail('unimplemented compiler $compiler');
689 } 712 }
690 if (executable.endsWith('.dart')) { 713 if (executable.endsWith('.dart')) {
691 // Run the compiler script via the Dart VM. 714 // Run the compiler script via the Dart VM.
692 args.insertRange(0, 1, executable); 715 args.insertRange(0, 1, executable);
693 executable = TestUtils.dartShellFileName(configuration); 716 executable = TestUtils.dartShellFileName(configuration);
694 } 717 }
695 return new Command(executable, args); 718 return new Command(executable, args);
696 } 719 }
(...skipping 27 matching lines...) Expand all
724 "${configuration['compiler']}-${configuration['runtime']}", 747 "${configuration['compiler']}-${configuration['runtime']}",
725 testUniqueName], '/'); 748 testUniqueName], '/');
726 749
727 TestUtils.mkdirRecursive(new Path('.'), new Path(generatedTestPath)); 750 TestUtils.mkdirRecursive(new Path('.'), new Path(generatedTestPath));
728 return new File(generatedTestPath).fullPathSync().replaceAll('\\', '/'); 751 return new File(generatedTestPath).fullPathSync().replaceAll('\\', '/');
729 } 752 }
730 753
731 String get scriptType() { 754 String get scriptType() {
732 switch (configuration['compiler']) { 755 switch (configuration['compiler']) {
733 case 'none': 756 case 'none':
757 case 'dart2dart':
734 return 'application/dart'; 758 return 'application/dart';
735 case 'frog': 759 case 'frog':
736 case 'dart2js': 760 case 'dart2js':
737 case 'dartc': 761 case 'dartc':
738 return 'text/javascript'; 762 return 'text/javascript';
739 default: 763 default:
740 Expect.fail('Non-web runtime, so no scriptType for: ' 764 Expect.fail('Non-web runtime, so no scriptType for: '
741 '${configuration["compiler"]}'); 765 '${configuration["compiler"]}');
742 return null; 766 return null;
743 } 767 }
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1250 }
1227 1251
1228 static String executableName(Map configuration) { 1252 static String executableName(Map configuration) {
1229 String suffix = executableSuffix(configuration['compiler']); 1253 String suffix = executableSuffix(configuration['compiler']);
1230 switch (configuration['compiler']) { 1254 switch (configuration['compiler']) {
1231 case 'none': 1255 case 'none':
1232 return 'dart$suffix'; 1256 return 'dart$suffix';
1233 case 'dartc': 1257 case 'dartc':
1234 return 'analyzer/bin/dart_analyzer$suffix'; 1258 return 'analyzer/bin/dart_analyzer$suffix';
1235 case 'dart2js': 1259 case 'dart2js':
1260 case 'dart2dart':
1236 var prefix = ''; 1261 var prefix = '';
1237 if (configuration['use_sdk']) { 1262 if (configuration['use_sdk']) {
1238 prefix = 'dart-sdk/bin/'; 1263 prefix = 'dart-sdk/bin/';
1239 } 1264 }
1240 if (configuration['host_checked']) { 1265 if (configuration['host_checked']) {
1241 // The script dart2js_developer is not in the SDK. 1266 // The script dart2js_developer is not in the SDK.
1242 return 'dart2js_developer$suffix'; 1267 return 'dart2js_developer$suffix';
1243 } else { 1268 } else {
1244 return '${prefix}dart2js$suffix'; 1269 return '${prefix}dart2js$suffix';
1245 } 1270 }
1246 case 'frog': 1271 case 'frog':
1247 return 'frog/bin/frog$suffix'; 1272 return 'frog/bin/frog$suffix';
1248 default: 1273 default:
1249 throw "Unknown executable for: ${configuration['compiler']}"; 1274 throw "Unknown executable for: ${configuration['compiler']}";
1250 } 1275 }
1251 } 1276 }
1252 1277
1253 static String compilerName(Map configuration) { 1278 static String compilerName(Map configuration) {
1254 String suffix = executableSuffix(configuration['compiler']); 1279 String suffix = executableSuffix(configuration['compiler']);
1255 switch (configuration['compiler']) { 1280 switch (configuration['compiler']) {
1256 case 'dartc': 1281 case 'dartc':
1257 case 'dart2js': 1282 case 'dart2js':
1283 case 'dart2dart':
1258 return executableName(configuration); 1284 return executableName(configuration);
1259 case 'frog': 1285 case 'frog':
1260 return 'frog/bin/frog$suffix'; 1286 return 'frog/bin/frog$suffix';
1261 default: 1287 default:
1262 throw "Unknown compiler for: ${configuration['compiler']}"; 1288 throw "Unknown compiler for: ${configuration['compiler']}";
1263 } 1289 }
1264 } 1290 }
1265 1291
1266 static String dartShellFileName(Map configuration) { 1292 static String dartShellFileName(Map configuration) {
1267 var name = configuration['dart']; 1293 var name = configuration['dart'];
1268 if (name == '') { 1294 if (name == '') {
1269 name = '${buildDir(configuration)}/${executableName(configuration)}'; 1295 name = '${buildDir(configuration)}/${executableName(configuration)}';
1270 } 1296 }
1271 ensureExists(name, configuration); 1297 ensureExists(name, configuration);
1272 return name; 1298 return name;
1273 } 1299 }
1274 1300
1275 static String d8FileName(Map configuration) { 1301 static String d8FileName(Map configuration) {
1276 var suffix = executableSuffix('d8'); 1302 var suffix = executableSuffix('d8');
1277 var d8 = '${buildDir(configuration)}/d8$suffix'; 1303 var d8 = '${buildDir(configuration)}/d8$suffix';
1278 ensureExists(d8, configuration); 1304 ensureExists(d8, configuration);
1279 return d8; 1305 return d8;
1280 } 1306 }
1281 1307
1308 static String vmFileName(Map configuration) {
1309 var suffix = executableSuffix('vm');
1310 var vm = '${buildDir(configuration)}/dart$suffix';
1311 ensureExists(vm, configuration);
1312 return vm;
1313 }
1314
1282 static void ensureExists(String filename, Map configuration) { 1315 static void ensureExists(String filename, Map configuration) {
1283 if (!configuration['list'] && !(new File(filename).existsSync())) { 1316 if (!configuration['list'] && !(new File(filename).existsSync())) {
1284 throw "Executable '$filename' does not exist"; 1317 throw "Executable '$filename' does not exist";
1285 } 1318 }
1286 } 1319 }
1287 1320
1288 static String compilerPath(Map configuration) { 1321 static String compilerPath(Map configuration) {
1289 if (configuration['compiler'] == 'none') { 1322 if (configuration['compiler'] == 'none') {
1290 return null; // No separate compiler for dartium tests. 1323 return null; // No separate compiler for dartium tests.
1291 } 1324 }
(...skipping 29 matching lines...) Expand all
1321 Path scriptPath = new Path.fromNative(scriptFile.fullPathSync()); 1354 Path scriptPath = new Path.fromNative(scriptFile.fullPathSync());
1322 return scriptPath.directoryPath.directoryPath; 1355 return scriptPath.directoryPath.directoryPath;
1323 } 1356 }
1324 1357
1325 static List<String> standardOptions(Map configuration) { 1358 static List<String> standardOptions(Map configuration) {
1326 List args = ["--ignore-unrecognized-flags"]; 1359 List args = ["--ignore-unrecognized-flags"];
1327 if (configuration["checked"]) { 1360 if (configuration["checked"]) {
1328 args.add('--enable_asserts'); 1361 args.add('--enable_asserts');
1329 args.add("--enable_type_checks"); 1362 args.add("--enable_type_checks");
1330 } 1363 }
1331 if (configuration["compiler"] == "dart2js") { 1364 String compiler = configuration["compiler"];
1365 if (compiler == "dart2js" || compiler == "dart2dart") {
1332 args = []; 1366 args = [];
1333 if (configuration["checked"]) { 1367 if (configuration["checked"]) {
1334 args.add('--enable-checked-mode'); 1368 args.add('--enable-checked-mode');
1335 } 1369 }
1336 args.add("--verbose"); 1370 args.add("--verbose");
1337 if (!isBrowserRuntime(configuration['runtime'])) { 1371 if (!isBrowserRuntime(configuration['runtime'])) {
1338 args.add("--allow-mock-compilation"); 1372 args.add("--allow-mock-compilation");
1339 } 1373 }
1340 } 1374 }
1341 return args; 1375 return args;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 * $noCrash tests are expected to be flaky but not crash 1429 * $noCrash tests are expected to be flaky but not crash
1396 * $pass tests are expected to pass 1430 * $pass tests are expected to pass
1397 * $failOk tests are expected to fail that we won't fix 1431 * $failOk tests are expected to fail that we won't fix
1398 * $fail tests are expected to fail that we should fix 1432 * $fail tests are expected to fail that we should fix
1399 * $crash tests are expected to crash that we should fix 1433 * $crash tests are expected to crash that we should fix
1400 * $timeout tests are allowed to timeout 1434 * $timeout tests are allowed to timeout
1401 """; 1435 """;
1402 print(report); 1436 print(report);
1403 } 1437 }
1404 } 1438 }
OLDNEW
« tools/testing/dart/test_options.dart ('K') | « tools/testing/dart/test_options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698