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

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

Issue 48323003: Implement fromEnvironment on bool, int, String in dart2js. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 bool negative = info.hasCompileError || 760 bool negative = info.hasCompileError ||
761 (configuration['checked'] && info.isNegativeIfChecked); 761 (configuration['checked'] && info.isNegativeIfChecked);
762 if (info.hasRuntimeError && hasRuntime) { 762 if (info.hasRuntimeError && hasRuntime) {
763 negative = true; 763 negative = true;
764 } 764 }
765 return negative; 765 return negative;
766 } 766 }
767 767
768 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { 768 List<Command> makeCommands(TestInformation info, var vmOptions, var args) {
769 var compiler = configuration['compiler']; 769 var compiler = configuration['compiler'];
770 List<String> sharedOptions = info.optionsFromFile['sharedOptions'];
770 switch (compiler) { 771 switch (compiler) {
771 case 'dart2js': 772 case 'dart2js':
772 args = new List.from(args); 773 args = new List.from(args);
773 String tempDir = createCompilationOutputDirectory(info.filePath); 774 String tempDir = createCompilationOutputDirectory(info.filePath);
775 if (sharedOptions != null) {
776 args.addAll(sharedOptions);
777 }
kustermann 2013/10/30 13:49:07 If you do it here, do it for dart2dart below as we
ngeoffray 2013/10/30 14:39:48 Done.
774 args.add('--out=$tempDir/out.js'); 778 args.add('--out=$tempDir/out.js');
775 779
776 var command = CommandBuilder.instance.getCompilationCommand( 780 var command = CommandBuilder.instance.getCompilationCommand(
777 compiler, "$tempDir/out.js", !useSdk, 781 compiler, "$tempDir/out.js", !useSdk,
778 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); 782 dart2JsBootstrapDependencies, compilerPath, args, configurationDir);
779 783
780 List<Command> commands = <Command>[command]; 784 List<Command> commands = <Command>[command];
781 if (info.hasCompileError) { 785 if (info.hasCompileError) {
782 // Do not attempt to run the compiled result. A compilation 786 // Do not attempt to run the compiled result. A compilation
783 // error should be reported by the compilation command. 787 // error should be reported by the compilation command.
784 } else if (configuration['runtime'] == 'd8') { 788 } else if (configuration['runtime'] == 'd8') {
785 commands.add(CommandBuilder.instance.getJSCommandlineCommand( 789 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
786 "d8", d8FileName, ['$tempDir/out.js'], configurationDir)); 790 "d8", d8FileName, ['$tempDir/out.js'], configurationDir));
787 } else if (configuration['runtime'] == 'jsshell') { 791 } else if (configuration['runtime'] == 'jsshell') {
788 commands.add(CommandBuilder.instance.getJSCommandlineCommand( 792 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
789 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir)); 793 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir));
790 } 794 }
791 return commands; 795 return commands;
792 case 'dart2dart': 796 case 'dart2dart':
793 args = new List.from(args); 797 args = new List.from(args);
ricow1 2013/10/30 13:51:19 we may need to add support for dart2dart as well
ngeoffray 2013/10/30 14:39:48 Done.
794 args.add('--output-type=dart'); 798 args.add('--output-type=dart');
795 String tempDir = createCompilationOutputDirectory(info.filePath); 799 String tempDir = createCompilationOutputDirectory(info.filePath);
796 args.add('--out=$tempDir/out.dart'); 800 args.add('--out=$tempDir/out.dart');
797 801
798 List<Command> commands = 802 List<Command> commands =
799 <Command>[CommandBuilder.instance.getCompilationCommand( 803 <Command>[CommandBuilder.instance.getCompilationCommand(
800 compiler, "$tempDir/out.dart", !useSdk, 804 compiler, "$tempDir/out.dart", !useSdk,
801 dart2JsBootstrapDependencies, compilerPath, args, 805 dart2JsBootstrapDependencies, compilerPath, args,
802 configurationDir)]; 806 configurationDir)];
803 if (info.hasCompileError) { 807 if (info.hasCompileError) {
804 // Do not attempt to run the compiled result. A compilation 808 // Do not attempt to run the compiled result. A compilation
805 // error should be reported by the compilation command. 809 // error should be reported by the compilation command.
806 } else if (configuration['runtime'] == 'vm') { 810 } else if (configuration['runtime'] == 'vm') {
807 // TODO(antonm): support checked. 811 // TODO(antonm): support checked.
808 var vmArguments = new List.from(vmOptions); 812 var vmArguments = new List.from(vmOptions);
809 vmArguments.addAll([ 813 vmArguments.addAll([
810 '--ignore-unrecognized-flags', '$tempDir/out.dart']); 814 '--ignore-unrecognized-flags', '$tempDir/out.dart']);
811 commands.add(CommandBuilder.instance.getVmCommand( 815 commands.add(CommandBuilder.instance.getVmCommand(
812 vmFileName, vmArguments, configurationDir)); 816 vmFileName, vmArguments, configurationDir));
813 } else { 817 } else {
814 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; 818 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart';
815 } 819 }
816 return commands; 820 return commands;
817 821
818 case 'none': 822 case 'none':
819 var arguments = new List.from(vmOptions); 823 var arguments = new List.from(vmOptions);
824 if (sharedOptions != null) {
825 arguments.addAll(sharedOptions);
826 }
kustermann 2013/10/30 13:49:07 There have to be other places where we setup the o
ngeoffray 2013/10/30 14:39:48 As discussed, we don't want to test this in drt/da
820 arguments.addAll(args); 827 arguments.addAll(args);
821 return <Command>[CommandBuilder.instance.getVmCommand( 828 return <Command>[CommandBuilder.instance.getVmCommand(
822 dartShellFileName, arguments, configurationDir)]; 829 dartShellFileName, arguments, configurationDir)];
823 830
824 case 'dartanalyzer': 831 case 'dartanalyzer':
825 case 'dart2analyzer': 832 case 'dart2analyzer':
826 return <Command>[makeAnalysisCommand(info, args)]; 833 return <Command>[makeAnalysisCommand(info, args)];
827 834
828 default: 835 default:
829 throw 'Unknown compiler ${configuration["compiler"]}'; 836 throw 'Unknown compiler ${configuration["compiler"]}';
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 * executing the copy command printed by the test script. 1406 * executing the copy command printed by the test script.
1400 * 1407 *
1401 * This method is static as the map is cached and shared amongst 1408 * This method is static as the map is cached and shared amongst
1402 * configurations, so it may not use [configuration]. 1409 * configurations, so it may not use [configuration].
1403 */ 1410 */
1404 Map readOptionsFromFile(Path filePath) { 1411 Map readOptionsFromFile(Path filePath) {
1405 if (filePath.segments().contains('co19')) { 1412 if (filePath.segments().contains('co19')) {
1406 return readOptionsFromCo19File(filePath); 1413 return readOptionsFromCo19File(filePath);
1407 } 1414 }
1408 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); 1415 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)");
1416 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)");
1409 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); 1417 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)");
1410 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); 1418 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)");
1411 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); 1419 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)");
1412 RegExp multiHtmlTestRegExp = 1420 RegExp multiHtmlTestRegExp =
1413 new RegExp(r"useHtmlIndividualConfiguration()"); 1421 new RegExp(r"useHtmlIndividualConfiguration()");
1414 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); 1422 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)");
1415 // TODO(gram) Clean these up once the old directives are not supported. 1423 // TODO(gram) Clean these up once the old directives are not supported.
1416 RegExp domImportRegExp = 1424 RegExp domImportRegExp =
1417 new RegExp(r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", 1425 new RegExp(r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)",
1418 multiLine: true); 1426 multiLine: true);
1419 1427
1420 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); 1428 var bytes = new File(filePath.toNativePath()).readAsBytesSync();
1421 String contents = decodeUtf8(bytes); 1429 String contents = decodeUtf8(bytes);
1422 bytes = null; 1430 bytes = null;
1423 1431
1424 // Find the options in the file. 1432 // Find the options in the file.
1425 List<List> result = new List<List>(); 1433 List<List> result = new List<List>();
1426 List<String> dartOptions; 1434 List<String> dartOptions;
1435 List<String> sharedOptions;
1427 String packageRoot; 1436 String packageRoot;
1428 1437
1429 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); 1438 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
1430 for (var match in matches) { 1439 for (var match in matches) {
1431 result.add(match[1].split(' ').where((e) => e != '').toList()); 1440 result.add(match[1].split(' ').where((e) => e != '').toList());
1432 } 1441 }
1433 if (result.isEmpty) result.add([]); 1442 if (result.isEmpty) result.add([]);
1434 1443
1435 matches = dartOptionsRegExp.allMatches(contents); 1444 matches = dartOptionsRegExp.allMatches(contents);
1436 for (var match in matches) { 1445 for (var match in matches) {
1437 if (dartOptions != null) { 1446 if (dartOptions != null) {
1438 throw new Exception( 1447 throw new Exception(
1439 'More than one "// DartOptions=" line in test $filePath'); 1448 'More than one "// DartOptions=" line in test $filePath');
1440 } 1449 }
1441 dartOptions = match[1].split(' ').where((e) => e != '').toList(); 1450 dartOptions = match[1].split(' ').where((e) => e != '').toList();
1442 } 1451 }
1443 1452
1453 matches = sharedOptionsRegExp.allMatches(contents);
1454 for (var match in matches) {
1455 if (sharedOptions != null) {
1456 throw new Exception(
1457 'More than one "// DartOptions=" line in test $filePath');
kustermann 2013/10/30 13:49:07 DartOptions => SharedOptions
ricow1 2013/10/30 13:51:19 DartOptions -> SharedOptions
1458 }
1459 sharedOptions = match[1].split(' ').where((e) => e != '').toList();
1460 }
1461
1444 matches = packageRootRegExp.allMatches(contents); 1462 matches = packageRootRegExp.allMatches(contents);
1445 for (var match in matches) { 1463 for (var match in matches) {
1446 if (packageRoot != null) { 1464 if (packageRoot != null) {
1447 throw new Exception( 1465 throw new Exception(
1448 'More than one "// PackageRoot=" line in test $filePath'); 1466 'More than one "// PackageRoot=" line in test $filePath');
1449 } 1467 }
1450 packageRoot = match[1]; 1468 packageRoot = match[1];
1451 if (packageRoot != 'none') { 1469 if (packageRoot != 'none') {
1452 // PackageRoot=none means that no package-root option should be given. 1470 // PackageRoot=none means that no package-root option should be given.
1453 packageRoot = '${filePath.directoryPath.join(new Path(packageRoot))}'; 1471 packageRoot = '${filePath.directoryPath.join(new Path(packageRoot))}';
(...skipping 20 matching lines...) Expand all
1474 // top-level "groups" so tests running nested groups will be no-ops. 1492 // top-level "groups" so tests running nested groups will be no-ops.
1475 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*"); 1493 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*");
1476 List<String> subtestNames = []; 1494 List<String> subtestNames = [];
1477 Iterator matchesIter = numTests.allMatches(contents).iterator; 1495 Iterator matchesIter = numTests.allMatches(contents).iterator;
1478 while(matchesIter.moveNext() && isMultiHtmlTest) { 1496 while(matchesIter.moveNext() && isMultiHtmlTest) {
1479 String fullMatch = matchesIter.current.group(0); 1497 String fullMatch = matchesIter.current.group(0);
1480 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); 1498 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1));
1481 } 1499 }
1482 1500
1483 return { "vmOptions": result, 1501 return { "vmOptions": result,
1502 "sharedOptions": sharedOptions,
1484 "dartOptions": dartOptions, 1503 "dartOptions": dartOptions,
1485 "packageRoot": packageRoot, 1504 "packageRoot": packageRoot,
1486 "hasCompileError": false, 1505 "hasCompileError": false,
1487 "hasRuntimeError": false, 1506 "hasRuntimeError": false,
1488 "hasStaticWarning" : false, 1507 "hasStaticWarning" : false,
1489 "otherScripts": otherScripts, 1508 "otherScripts": otherScripts,
1490 "isMultitest": isMultitest, 1509 "isMultitest": isMultitest,
1491 "isMultiHtmlTest": isMultiHtmlTest, 1510 "isMultiHtmlTest": isMultiHtmlTest,
1492 "subtestNames": subtestNames, 1511 "subtestNames": subtestNames,
1493 "isolateStubs": isolateStubs, 1512 "isolateStubs": isolateStubs,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 // expectations accordingly. 1561 // expectations accordingly.
1543 1562
1544 // Using stderr.writeString to avoid breaking dartc/junit_tests 1563 // Using stderr.writeString to avoid breaking dartc/junit_tests
1545 // which parses the output of the --list option. 1564 // which parses the output of the --list option.
1546 stderr.writeln( 1565 stderr.writeln(
1547 "Warning: deprecated @dynamic-type-error tag used in $filePath"); 1566 "Warning: deprecated @dynamic-type-error tag used in $filePath");
1548 } 1567 }
1549 1568
1550 return { 1569 return {
1551 "vmOptions": <List>[[]], 1570 "vmOptions": <List>[[]],
1571 "sharedOptions": null,
1552 "dartOptions": null, 1572 "dartOptions": null,
1553 "packageRoot": null, 1573 "packageRoot": null,
1554 "hasCompileError": hasCompileError, 1574 "hasCompileError": hasCompileError,
1555 "hasRuntimeError": hasRuntimeError, 1575 "hasRuntimeError": hasRuntimeError,
1556 "hasStaticWarning" : hasStaticWarning, 1576 "hasStaticWarning" : hasStaticWarning,
1557 "otherScripts": <String>[], 1577 "otherScripts": <String>[],
1558 "isMultitest": isMultitest, 1578 "isMultitest": isMultitest,
1559 "isMultiHtmlTest": false, 1579 "isMultiHtmlTest": false,
1560 "subtestNames": <String>[], 1580 "subtestNames": <String>[],
1561 "isolateStubs": '', 1581 "isolateStubs": '',
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 * $pass tests are expected to pass 2058 * $pass tests are expected to pass
2039 * $failOk tests are expected to fail that we won't fix 2059 * $failOk tests are expected to fail that we won't fix
2040 * $fail tests are expected to fail that we should fix 2060 * $fail tests are expected to fail that we should fix
2041 * $crash tests are expected to crash that we should fix 2061 * $crash tests are expected to crash that we should fix
2042 * $timeout tests are allowed to timeout 2062 * $timeout tests are allowed to timeout
2043 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2063 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2044 """; 2064 """;
2045 print(report); 2065 print(report);
2046 } 2066 }
2047 } 2067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698