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

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

Issue 47703006: Implement SharedOptions in test scripts. (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
« no previous file with comments | « no previous file | no next file » | 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 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 args.addAll(sharedOptions);
774 args.add('--out=$tempDir/out.js'); 776 args.add('--out=$tempDir/out.js');
775 777
776 var command = CommandBuilder.instance.getCompilationCommand( 778 var command = CommandBuilder.instance.getCompilationCommand(
777 compiler, "$tempDir/out.js", !useSdk, 779 compiler, "$tempDir/out.js", !useSdk,
778 dart2JsBootstrapDependencies, compilerPath, args, configurationDir); 780 dart2JsBootstrapDependencies, compilerPath, args, configurationDir);
779 781
780 List<Command> commands = <Command>[command]; 782 List<Command> commands = <Command>[command];
781 if (info.hasCompileError) { 783 if (info.hasCompileError) {
782 // Do not attempt to run the compiled result. A compilation 784 // Do not attempt to run the compiled result. A compilation
783 // error should be reported by the compilation command. 785 // error should be reported by the compilation command.
784 } else if (configuration['runtime'] == 'd8') { 786 } else if (configuration['runtime'] == 'd8') {
785 commands.add(CommandBuilder.instance.getJSCommandlineCommand( 787 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
786 "d8", d8FileName, ['$tempDir/out.js'], configurationDir)); 788 "d8", d8FileName, ['$tempDir/out.js'], configurationDir));
787 } else if (configuration['runtime'] == 'jsshell') { 789 } else if (configuration['runtime'] == 'jsshell') {
788 commands.add(CommandBuilder.instance.getJSCommandlineCommand( 790 commands.add(CommandBuilder.instance.getJSCommandlineCommand(
789 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir)); 791 "jsshell", jsShellFileName, ['$tempDir/out.js'], configurationDir));
790 } 792 }
791 return commands; 793 return commands;
792 case 'dart2dart': 794 case 'dart2dart':
793 args = new List.from(args); 795 args = new List.from(args);
796 args.addAll(sharedOptions);
794 args.add('--output-type=dart'); 797 args.add('--output-type=dart');
795 String tempDir = createCompilationOutputDirectory(info.filePath); 798 String tempDir = createCompilationOutputDirectory(info.filePath);
796 args.add('--out=$tempDir/out.dart'); 799 args.add('--out=$tempDir/out.dart');
797 800
798 List<Command> commands = 801 List<Command> commands =
799 <Command>[CommandBuilder.instance.getCompilationCommand( 802 <Command>[CommandBuilder.instance.getCompilationCommand(
800 compiler, "$tempDir/out.dart", !useSdk, 803 compiler, "$tempDir/out.dart", !useSdk,
801 dart2JsBootstrapDependencies, compilerPath, args, 804 dart2JsBootstrapDependencies, compilerPath, args,
802 configurationDir)]; 805 configurationDir)];
803 if (info.hasCompileError) { 806 if (info.hasCompileError) {
804 // Do not attempt to run the compiled result. A compilation 807 // Do not attempt to run the compiled result. A compilation
805 // error should be reported by the compilation command. 808 // error should be reported by the compilation command.
806 } else if (configuration['runtime'] == 'vm') { 809 } else if (configuration['runtime'] == 'vm') {
807 // TODO(antonm): support checked. 810 // TODO(antonm): support checked.
808 var vmArguments = new List.from(vmOptions); 811 var vmArguments = new List.from(vmOptions);
809 vmArguments.addAll([ 812 vmArguments.addAll([
810 '--ignore-unrecognized-flags', '$tempDir/out.dart']); 813 '--ignore-unrecognized-flags', '$tempDir/out.dart']);
811 commands.add(CommandBuilder.instance.getVmCommand( 814 commands.add(CommandBuilder.instance.getVmCommand(
812 vmFileName, vmArguments, configurationDir)); 815 vmFileName, vmArguments, configurationDir));
813 } else { 816 } else {
814 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; 817 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart';
815 } 818 }
816 return commands; 819 return commands;
817 820
818 case 'none': 821 case 'none':
819 var arguments = new List.from(vmOptions); 822 var arguments = new List.from(vmOptions);
823 arguments.addAll(sharedOptions);
820 arguments.addAll(args); 824 arguments.addAll(args);
821 return <Command>[CommandBuilder.instance.getVmCommand( 825 return <Command>[CommandBuilder.instance.getVmCommand(
822 dartShellFileName, arguments, configurationDir)]; 826 dartShellFileName, arguments, configurationDir)];
823 827
824 case 'dartanalyzer': 828 case 'dartanalyzer':
825 case 'dart2analyzer': 829 case 'dart2analyzer':
826 return <Command>[makeAnalysisCommand(info, args)]; 830 return <Command>[makeAnalysisCommand(info, args)];
827 831
828 default: 832 default:
829 throw 'Unknown compiler ${configuration["compiler"]}'; 833 throw 'Unknown compiler ${configuration["compiler"]}';
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 * Special options for individual tests are currently specified in various 1349 * Special options for individual tests are currently specified in various
1346 * ways: with comments directly in test files, by using certain imports, or by 1350 * ways: with comments directly in test files, by using certain imports, or by
1347 * creating additional files in the test directories. 1351 * creating additional files in the test directories.
1348 * 1352 *
1349 * Here is a list of options that are used by 'test.dart' today: 1353 * Here is a list of options that are used by 'test.dart' today:
1350 * - Flags can be passed to the vm or dartium process that runs the test by 1354 * - Flags can be passed to the vm or dartium process that runs the test by
1351 * adding a comment to the test file: 1355 * adding a comment to the test file:
1352 * 1356 *
1353 * // VMOptions=--flag1 --flag2 1357 * // VMOptions=--flag1 --flag2
1354 * 1358 *
1359 * - Flags can be passed to dart2js, dart2dart or vm by adding a comment
1360 * to the test file:
1361 *
1362 * // SharedOptions=--flag1 --flag2
1363 *
1355 * - Flags can be passed to the dart script that contains the test also 1364 * - Flags can be passed to the dart script that contains the test also
1356 * using comments, as follows: 1365 * using comments, as follows:
1357 * 1366 *
1358 * // DartOptions=--flag1 --flag2 1367 * // DartOptions=--flag1 --flag2
1359 * 1368 *
1360 * - For tests that depend on compiling other files with dart2js (e.g. 1369 * - For tests that depend on compiling other files with dart2js (e.g.
1361 * isolate tests that use multiple source scripts), you can specify 1370 * isolate tests that use multiple source scripts), you can specify
1362 * additional files to compile using a comment too, as follows: 1371 * additional files to compile using a comment too, as follows:
1363 * 1372 *
1364 * // OtherScripts=file1.dart file2.dart 1373 * // OtherScripts=file1.dart file2.dart
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 * executing the copy command printed by the test script. 1408 * executing the copy command printed by the test script.
1400 * 1409 *
1401 * This method is static as the map is cached and shared amongst 1410 * This method is static as the map is cached and shared amongst
1402 * configurations, so it may not use [configuration]. 1411 * configurations, so it may not use [configuration].
1403 */ 1412 */
1404 Map readOptionsFromFile(Path filePath) { 1413 Map readOptionsFromFile(Path filePath) {
1405 if (filePath.segments().contains('co19')) { 1414 if (filePath.segments().contains('co19')) {
1406 return readOptionsFromCo19File(filePath); 1415 return readOptionsFromCo19File(filePath);
1407 } 1416 }
1408 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); 1417 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)");
1418 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)");
1409 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); 1419 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)");
1410 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); 1420 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)");
1411 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); 1421 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)");
1412 RegExp multiHtmlTestRegExp = 1422 RegExp multiHtmlTestRegExp =
1413 new RegExp(r"useHtmlIndividualConfiguration()"); 1423 new RegExp(r"useHtmlIndividualConfiguration()");
1414 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); 1424 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)");
1415 // TODO(gram) Clean these up once the old directives are not supported. 1425 // TODO(gram) Clean these up once the old directives are not supported.
1416 RegExp domImportRegExp = 1426 RegExp domImportRegExp =
1417 new RegExp(r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", 1427 new RegExp(r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)",
1418 multiLine: true); 1428 multiLine: true);
1419 1429
1420 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); 1430 var bytes = new File(filePath.toNativePath()).readAsBytesSync();
1421 String contents = decodeUtf8(bytes); 1431 String contents = decodeUtf8(bytes);
1422 bytes = null; 1432 bytes = null;
1423 1433
1424 // Find the options in the file. 1434 // Find the options in the file.
1425 List<List> result = new List<List>(); 1435 List<List> result = new List<List>();
1426 List<String> dartOptions; 1436 List<String> dartOptions;
1437 List<String> sharedOptions;
1427 String packageRoot; 1438 String packageRoot;
1428 1439
1429 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); 1440 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
1430 for (var match in matches) { 1441 for (var match in matches) {
1431 result.add(match[1].split(' ').where((e) => e != '').toList()); 1442 result.add(match[1].split(' ').where((e) => e != '').toList());
1432 } 1443 }
1433 if (result.isEmpty) result.add([]); 1444 if (result.isEmpty) result.add([]);
1434 1445
1435 matches = dartOptionsRegExp.allMatches(contents); 1446 matches = dartOptionsRegExp.allMatches(contents);
1436 for (var match in matches) { 1447 for (var match in matches) {
1437 if (dartOptions != null) { 1448 if (dartOptions != null) {
1438 throw new Exception( 1449 throw new Exception(
1439 'More than one "// DartOptions=" line in test $filePath'); 1450 'More than one "// DartOptions=" line in test $filePath');
1440 } 1451 }
1441 dartOptions = match[1].split(' ').where((e) => e != '').toList(); 1452 dartOptions = match[1].split(' ').where((e) => e != '').toList();
1442 } 1453 }
1443 1454
1455 matches = sharedOptionsRegExp.allMatches(contents);
1456 for (var match in matches) {
1457 if (sharedOptions != null) {
1458 throw new Exception(
1459 'More than one "// SharedOptions=" line in test $filePath');
1460 }
1461 sharedOptions = match[1].split(' ').where((e) => e != '').toList();
1462 }
1463
1444 matches = packageRootRegExp.allMatches(contents); 1464 matches = packageRootRegExp.allMatches(contents);
1445 for (var match in matches) { 1465 for (var match in matches) {
1446 if (packageRoot != null) { 1466 if (packageRoot != null) {
1447 throw new Exception( 1467 throw new Exception(
1448 'More than one "// PackageRoot=" line in test $filePath'); 1468 'More than one "// PackageRoot=" line in test $filePath');
1449 } 1469 }
1450 packageRoot = match[1]; 1470 packageRoot = match[1];
1451 if (packageRoot != 'none') { 1471 if (packageRoot != 'none') {
1452 // PackageRoot=none means that no package-root option should be given. 1472 // PackageRoot=none means that no package-root option should be given.
1453 packageRoot = '${filePath.directoryPath.join(new Path(packageRoot))}'; 1473 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. 1494 // top-level "groups" so tests running nested groups will be no-ops.
1475 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*"); 1495 RegExp numTests = new RegExp(r"\s*[^/]\s*group\('[^,']*");
1476 List<String> subtestNames = []; 1496 List<String> subtestNames = [];
1477 Iterator matchesIter = numTests.allMatches(contents).iterator; 1497 Iterator matchesIter = numTests.allMatches(contents).iterator;
1478 while(matchesIter.moveNext() && isMultiHtmlTest) { 1498 while(matchesIter.moveNext() && isMultiHtmlTest) {
1479 String fullMatch = matchesIter.current.group(0); 1499 String fullMatch = matchesIter.current.group(0);
1480 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); 1500 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1));
1481 } 1501 }
1482 1502
1483 return { "vmOptions": result, 1503 return { "vmOptions": result,
1504 "sharedOptions": sharedOptions == null ? [] : sharedOptions,
1484 "dartOptions": dartOptions, 1505 "dartOptions": dartOptions,
1485 "packageRoot": packageRoot, 1506 "packageRoot": packageRoot,
1486 "hasCompileError": false, 1507 "hasCompileError": false,
1487 "hasRuntimeError": false, 1508 "hasRuntimeError": false,
1488 "hasStaticWarning" : false, 1509 "hasStaticWarning" : false,
1489 "otherScripts": otherScripts, 1510 "otherScripts": otherScripts,
1490 "isMultitest": isMultitest, 1511 "isMultitest": isMultitest,
1491 "isMultiHtmlTest": isMultiHtmlTest, 1512 "isMultiHtmlTest": isMultiHtmlTest,
1492 "subtestNames": subtestNames, 1513 "subtestNames": subtestNames,
1493 "isolateStubs": isolateStubs, 1514 "isolateStubs": isolateStubs,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 // expectations accordingly. 1563 // expectations accordingly.
1543 1564
1544 // Using stderr.writeString to avoid breaking dartc/junit_tests 1565 // Using stderr.writeString to avoid breaking dartc/junit_tests
1545 // which parses the output of the --list option. 1566 // which parses the output of the --list option.
1546 stderr.writeln( 1567 stderr.writeln(
1547 "Warning: deprecated @dynamic-type-error tag used in $filePath"); 1568 "Warning: deprecated @dynamic-type-error tag used in $filePath");
1548 } 1569 }
1549 1570
1550 return { 1571 return {
1551 "vmOptions": <List>[[]], 1572 "vmOptions": <List>[[]],
1573 "sharedOptions": <String>[],
1552 "dartOptions": null, 1574 "dartOptions": null,
1553 "packageRoot": null, 1575 "packageRoot": null,
1554 "hasCompileError": hasCompileError, 1576 "hasCompileError": hasCompileError,
1555 "hasRuntimeError": hasRuntimeError, 1577 "hasRuntimeError": hasRuntimeError,
1556 "hasStaticWarning" : hasStaticWarning, 1578 "hasStaticWarning" : hasStaticWarning,
1557 "otherScripts": <String>[], 1579 "otherScripts": <String>[],
1558 "isMultitest": isMultitest, 1580 "isMultitest": isMultitest,
1559 "isMultiHtmlTest": false, 1581 "isMultiHtmlTest": false,
1560 "subtestNames": <String>[], 1582 "subtestNames": <String>[],
1561 "isolateStubs": '', 1583 "isolateStubs": '',
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 * $pass tests are expected to pass 2060 * $pass tests are expected to pass
2039 * $failOk tests are expected to fail that we won't fix 2061 * $failOk tests are expected to fail that we won't fix
2040 * $fail tests are expected to fail that we should fix 2062 * $fail tests are expected to fail that we should fix
2041 * $crash tests are expected to crash that we should fix 2063 * $crash tests are expected to crash that we should fix
2042 * $timeout tests are allowed to timeout 2064 * $timeout tests are allowed to timeout
2043 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2065 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2044 """; 2066 """;
2045 print(report); 2067 print(report);
2046 } 2068 }
2047 } 2069 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698