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

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

Issue 14103003: Remove use of Expect from test scripts and idlparser_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Run test scripts in checked mode. Created 7 years, 8 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
« tools/test.py ('K') | « tools/testing/dart/multitest.dart ('k') | 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 bool hasCompileError; 390 bool hasCompileError;
391 bool hasRuntimeError; 391 bool hasRuntimeError;
392 bool isNegativeIfChecked; 392 bool isNegativeIfChecked;
393 bool hasFatalTypeErrors; 393 bool hasFatalTypeErrors;
394 Set<String> multitestOutcome; 394 Set<String> multitestOutcome;
395 395
396 TestInformation(this.filePath, this.optionsFromFile, 396 TestInformation(this.filePath, this.optionsFromFile,
397 this.hasCompileError, this.hasRuntimeError, 397 this.hasCompileError, this.hasRuntimeError,
398 this.isNegativeIfChecked, this.hasFatalTypeErrors, 398 this.isNegativeIfChecked, this.hasFatalTypeErrors,
399 this.multitestOutcome) { 399 this.multitestOutcome) {
400 Expect.isTrue(filePath.isAbsolute); 400 assert(filePath.isAbsolute);
401 } 401 }
402 } 402 }
403 403
404 /** 404 /**
405 * A standard [TestSuite] implementation that searches for tests in a 405 * A standard [TestSuite] implementation that searches for tests in a
406 * directory, and creates [TestCase]s that compile and/or run them. 406 * directory, and creates [TestCase]s that compile and/or run them.
407 */ 407 */
408 class StandardTestSuite extends TestSuite { 408 class StandardTestSuite extends TestSuite {
409 final Path suiteDir; 409 final Path suiteDir;
410 final List<String> statusFilePaths; 410 final List<String> statusFilePaths;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 * If DumpRenderTree/Dartium is required, and not yet updated, waits for 521 * If DumpRenderTree/Dartium is required, and not yet updated, waits for
522 * the update then completes. Otherwise completes immediately. 522 * the update then completes. Otherwise completes immediately.
523 */ 523 */
524 Future updateDartium() { 524 Future updateDartium() {
525 var completer = new Completer(); 525 var completer = new Completer();
526 var updater = runtimeUpdater(configuration); 526 var updater = runtimeUpdater(configuration);
527 if (updater == null || updater.updated) { 527 if (updater == null || updater.updated) {
528 return new Future.immediate(null); 528 return new Future.immediate(null);
529 } 529 }
530 530
531 Expect.isTrue(updater.isActive); 531 assert(updater.isActive);
532 updater.onUpdated.add(() => completer.complete(null)); 532 updater.onUpdated.add(() => completer.complete(null));
533 533
534 return completer.future; 534 return completer.future;
535 } 535 }
536 536
537 /** 537 /**
538 * Reads the status files and completes with the parsed expectations. 538 * Reads the status files and completes with the parsed expectations.
539 */ 539 */
540 Future<TestExpectations> readExpectations() { 540 Future<TestExpectations> readExpectations() {
541 var completer = new Completer(); 541 var completer = new Completer();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // Multitests do not run on browsers. 630 // Multitests do not run on browsers.
631 if (TestUtils.isBrowserRuntime(configuration['runtime'])) return; 631 if (TestUtils.isBrowserRuntime(configuration['runtime'])) return;
632 // Multitests are in [build directory]/generated_tests/... . 632 // Multitests are in [build directory]/generated_tests/... .
633 // The test name will be '[test filename (no extension)]/[multitest key]. 633 // The test name will be '[test filename (no extension)]/[multitest key].
634 String name = filePath.filenameWithoutExtension; 634 String name = filePath.filenameWithoutExtension;
635 int middle = name.lastIndexOf('_'); 635 int middle = name.lastIndexOf('_');
636 testName = '${name.substring(0, middle)}/${name.substring(middle + 1)}'; 636 testName = '${name.substring(0, middle)}/${name.substring(middle + 1)}';
637 } else { 637 } else {
638 // The test name is the relative path from the test suite directory to 638 // The test name is the relative path from the test suite directory to
639 // the test, with the .dart extension removed. 639 // the test, with the .dart extension removed.
640 Expect.isTrue(filePath.toNativePath().startsWith( 640 assert(filePath.toNativePath().startsWith(
641 suiteDir.toNativePath())); 641 suiteDir.toNativePath()));
642 var testNamePath = filePath.relativeTo(suiteDir); 642 var testNamePath = filePath.relativeTo(suiteDir);
643 Expect.isTrue(testNamePath.extension == 'dart'); 643 assert(testNamePath.extension == 'dart');
644 if (testNamePath.extension == 'dart') { 644 if (testNamePath.extension == 'dart') {
645 testName = testNamePath.directoryPath.append( 645 testName = testNamePath.directoryPath.append(
646 testNamePath.filenameWithoutExtension).toString(); 646 testNamePath.filenameWithoutExtension).toString();
647 } 647 }
648 } 648 }
649 int shards = configuration['shards']; 649 int shards = configuration['shards'];
650 if (shards > 1) { 650 if (shards > 1) {
651 int shard = configuration['shard']; 651 int shard = configuration['shard'];
652 if (testName.hashCode % shards != shard - 1) { 652 if (testName.hashCode % shards != shard - 1) {
653 return; 653 return;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // format of the error line 710 // format of the error line
711 if (info.hasFatalTypeErrors) { 711 if (info.hasFatalTypeErrors) {
712 isNegative = true; 712 isNegative = true;
713 } 713 }
714 } 714 }
715 715
716 var commonArguments = commonArgumentsFromFile(info.filePath, 716 var commonArguments = commonArgumentsFromFile(info.filePath,
717 info.optionsFromFile); 717 info.optionsFromFile);
718 718
719 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); 719 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile);
720 Expect.isFalse(vmOptionsList.isEmpty, "empty vmOptionsList"); 720 assert(!vmOptionsList.isEmpty);
721 721
722 for (var vmOptions in vmOptionsList) { 722 for (var vmOptions in vmOptionsList) {
723 doTest(new TestCase('$suiteName/$testName', 723 doTest(new TestCase('$suiteName/$testName',
724 makeCommands(info, vmOptions, commonArguments), 724 makeCommands(info, vmOptions, commonArguments),
725 configuration, 725 configuration,
726 completeHandler, 726 completeHandler,
727 expectations, 727 expectations,
728 isNegative: isNegative, 728 isNegative: isNegative,
729 info: info)); 729 info: info));
730 } 730 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 829
830 var fileString = file.toString(); 830 var fileString = file.toString();
831 if (fileString.startsWith(buildDir.toString())) { 831 if (fileString.startsWith(buildDir.toString())) {
832 var fileRelativeToBuildDir = file.relativeTo(buildDir); 832 var fileRelativeToBuildDir = file.relativeTo(buildDir);
833 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; 833 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir";
834 } else if (fileString.startsWith(dartDir.toString())) { 834 } else if (fileString.startsWith(dartDir.toString())) {
835 var fileRelativeToDartDir = file.relativeTo(dartDir); 835 var fileRelativeToDartDir = file.relativeTo(dartDir);
836 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; 836 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir";
837 } 837 }
838 // Unreachable 838 // Unreachable
839 Expect.fail('This should be unreachable.'); 839 print("Cannot create URL for path $file. Not in build or dart directory.");
840 exit(1);
840 } 841 }
841 842
842 String _getUriForBrowserTest(TestInformation info, 843 String _getUriForBrowserTest(TestInformation info,
843 String pathComponent, 844 String pathComponent,
844 subtestNames, 845 subtestNames,
845 subtestIndex) { 846 subtestIndex) {
846 // Note: If we run test.py with the "--list" option, no http servers 847 // Note: If we run test.py with the "--list" option, no http servers
847 // will be started. So we use PORT/CROSS_ORIGIN_PORT instead of real ports. 848 // will be started. So we use PORT/CROSS_ORIGIN_PORT instead of real ports.
848 var serverPort = "PORT"; 849 var serverPort = "PORT";
849 var crossOriginPort = "CROSS_ORIGIN_PORT"; 850 var crossOriginPort = "CROSS_ORIGIN_PORT";
850 if (!configuration['list']) { 851 if (!configuration['list']) {
851 Expect.isTrue(configuration.containsKey('_servers_')); 852 assert(configuration.containsKey('_servers_'));
852 serverPort = configuration['_servers_'].port; 853 serverPort = configuration['_servers_'].port;
853 crossOriginPort = configuration['_servers_'].crossOriginPort; 854 crossOriginPort = configuration['_servers_'].crossOriginPort;
854 } 855 }
855 856
856 var url= 'http://127.0.0.1:$serverPort$pathComponent' 857 var url= 'http://127.0.0.1:$serverPort$pathComponent'
857 '?crossOriginPort=$crossOriginPort'; 858 '?crossOriginPort=$crossOriginPort';
858 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { 859 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) {
859 url= '${url}&group=${subtestNames[subtestIndex]}'; 860 url= '${url}&group=${subtestNames[subtestIndex]}';
860 } 861 }
861 return url; 862 return url;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 List<Command> commands = []; 964 List<Command> commands = [];
964 if (compiler != 'none') { 965 if (compiler != 'none') {
965 commands.add(_compileCommand( 966 commands.add(_compileCommand(
966 dartWrapperFilename, compiledDartWrapperFilename, 967 dartWrapperFilename, compiledDartWrapperFilename,
967 compiler, tempDir, vmOptions, optionsFromFile)); 968 compiler, tempDir, vmOptions, optionsFromFile));
968 969
969 // some tests require compiling multiple input scripts. 970 // some tests require compiling multiple input scripts.
970 List<String> otherScripts = optionsFromFile['otherScripts']; 971 List<String> otherScripts = optionsFromFile['otherScripts'];
971 for (String name in otherScripts) { 972 for (String name in otherScripts) {
972 Path namePath = new Path(name); 973 Path namePath = new Path(name);
973 Expect.equals(namePath.extension, 'dart'); 974 assert(namePath.extension == 'dart');
974 String baseName = namePath.filenameWithoutExtension; 975 String baseName = namePath.filenameWithoutExtension;
975 Path fromPath = filePath.directoryPath.join(namePath); 976 Path fromPath = filePath.directoryPath.join(namePath);
976 commands.add(_compileCommand( 977 commands.add(_compileCommand(
977 fromPath.toNativePath(), '$tempDir/$baseName.js', 978 fromPath.toNativePath(), '$tempDir/$baseName.js',
978 compiler, tempDir, vmOptions, optionsFromFile)); 979 compiler, tempDir, vmOptions, optionsFromFile));
979 } 980 }
980 } 981 }
981 982
982 // Variables for browser multi-tests. 983 // Variables for browser multi-tests.
983 List<String> subtestNames = info.optionsFromFile['subtestNames']; 984 List<String> subtestNames = info.optionsFromFile['subtestNames'];
(...skipping 21 matching lines...) Expand all
1005 '--timeout=${configuration["timeout"]~/2}', 1006 '--timeout=${configuration["timeout"]~/2}',
1006 '--out=$fullHtmlPath']; 1007 '--out=$fullHtmlPath'];
1007 if (runtime == 'dartium') { 1008 if (runtime == 'dartium') {
1008 args.add('--executable=$dartiumFilename'); 1009 args.add('--executable=$dartiumFilename');
1009 } 1010 }
1010 if (subtestIndex != 0) { 1011 if (subtestIndex != 0) {
1011 args.add('--force-refresh'); 1012 args.add('--force-refresh');
1012 } 1013 }
1013 commandSet.add(new Command('python', args)); 1014 commandSet.add(new Command('python', args));
1014 } else { 1015 } else {
1015 Expect.isTrue(runtime == "drt"); 1016 if (runtime != "drt") {
1017 print("Unknown runtime $runtime");
1018 exit(1);
1019 }
1016 1020
1017 var dartFlags = []; 1021 var dartFlags = [];
1018 var dumpRenderTreeOptions = []; 1022 var dumpRenderTreeOptions = [];
1019 1023
1020 dumpRenderTreeOptions.add('--no-timeout'); 1024 dumpRenderTreeOptions.add('--no-timeout');
1021 1025
1022 if (compiler == 'none' || compiler == 'dart2dart') { 1026 if (compiler == 'none' || compiler == 'dart2dart') {
1023 dartFlags.add('--ignore-unrecognized-flags'); 1027 dartFlags.add('--ignore-unrecognized-flags');
1024 if (configuration["checked"]) { 1028 if (configuration["checked"]) {
1025 dartFlags.add('--enable_asserts'); 1029 dartFlags.add('--enable_asserts');
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 case 'dart2dart': 1082 case 'dart2dart':
1079 String packageRoot = 1083 String packageRoot =
1080 packageRootArgument(optionsFromFile['packageRoot']); 1084 packageRootArgument(optionsFromFile['packageRoot']);
1081 if (packageRoot != null) { 1085 if (packageRoot != null) {
1082 args.add(packageRoot); 1086 args.add(packageRoot);
1083 } 1087 }
1084 args.add('--out=$outputFile'); 1088 args.add('--out=$outputFile');
1085 args.add(inputFile); 1089 args.add(inputFile);
1086 break; 1090 break;
1087 default: 1091 default:
1088 Expect.fail('unimplemented compiler $compiler'); 1092 print('unimplemented compiler $compiler');
1093 exit(1);
1089 } 1094 }
1090 if (executable.endsWith('.dart')) { 1095 if (executable.endsWith('.dart')) {
1091 // Run the compiler script via the Dart VM. 1096 // Run the compiler script via the Dart VM.
1092 args.insertRange(0, 1, executable); 1097 args.insertRange(0, 1, executable);
1093 executable = dartShellFileName; 1098 executable = dartShellFileName;
1094 } 1099 }
1095 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) { 1100 if (['dart2js', 'dart2dart'].contains(configuration['compiler'])) {
1096 return new CompilationCommand(outputFile, 1101 return new CompilationCommand(outputFile,
1097 !useSdk, 1102 !useSdk,
1098 dart2JsBootstrapDependencies, 1103 dart2JsBootstrapDependencies,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 String get scriptType { 1150 String get scriptType {
1146 switch (configuration['compiler']) { 1151 switch (configuration['compiler']) {
1147 case 'none': 1152 case 'none':
1148 case 'dart2dart': 1153 case 'dart2dart':
1149 return 'application/dart'; 1154 return 'application/dart';
1150 case 'dart2js': 1155 case 'dart2js':
1151 case 'dartanalyzer': 1156 case 'dartanalyzer':
1152 case 'dartc': 1157 case 'dartc':
1153 return 'text/javascript'; 1158 return 'text/javascript';
1154 default: 1159 default:
1155 Expect.fail('Non-web runtime, so no scriptType for: ' 1160 print('Non-web runtime, so no scriptType for: '
1156 '${configuration["compiler"]}'); 1161 '${configuration["compiler"]}');
1162 exit(1);
1157 return null; 1163 return null;
1158 } 1164 }
1159 } 1165 }
1160 1166
1161 bool get hasRuntime { 1167 bool get hasRuntime {
1162 switch(configuration['runtime']) { 1168 switch(configuration['runtime']) {
1163 case 'none': 1169 case 'none':
1164 return false; 1170 return false;
1165 default: 1171 default:
1166 return true; 1172 return true;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 args.add(packageRoot); 1215 args.add(packageRoot);
1210 } 1216 }
1211 args.addAll(additionalOptions(filePath)); 1217 args.addAll(additionalOptions(filePath));
1212 if (configuration['analyzer']) { 1218 if (configuration['analyzer']) {
1213 args.add('--machine'); 1219 args.add('--machine');
1214 } 1220 }
1215 1221
1216 bool isMultitest = optionsFromFile["isMultitest"]; 1222 bool isMultitest = optionsFromFile["isMultitest"];
1217 List<String> dartOptions = optionsFromFile["dartOptions"]; 1223 List<String> dartOptions = optionsFromFile["dartOptions"];
1218 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile); 1224 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile);
1219 Expect.isTrue(!isMultitest || dartOptions == null); 1225 assert(!isMultitest || dartOptions == null);
1220 if (dartOptions == null) { 1226 if (dartOptions == null) {
1221 args.add(filePath.toNativePath()); 1227 args.add(filePath.toNativePath());
1222 } else { 1228 } else {
1223 var executable_name = dartOptions[0]; 1229 var executable_name = dartOptions[0];
1224 // TODO(ager): Get rid of this hack when the runtime checkout goes away. 1230 // TODO(ager): Get rid of this hack when the runtime checkout goes away.
1225 var file = new File(executable_name); 1231 var file = new File(executable_name);
1226 if (!file.existsSync()) { 1232 if (!file.existsSync()) {
1227 executable_name = '../$executable_name'; 1233 executable_name = '../$executable_name';
1228 Expect.isTrue(new File(executable_name).existsSync()); 1234 assert(new File(executable_name).existsSync());
1229 dartOptions[0] = executable_name; 1235 dartOptions[0] = executable_name;
1230 } 1236 }
1231 args.addAll(dartOptions); 1237 args.addAll(dartOptions);
1232 } 1238 }
1233 1239
1234 return args; 1240 return args;
1235 } 1241 }
1236 1242
1237 String packageRoot(String packageRootFromFile) { 1243 String packageRoot(String packageRootFromFile) {
1238 if (packageRootFromFile == "none") { 1244 if (packageRootFromFile == "none") {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 new Path(new Directory.current().path); 1709 new Path(new Directory.current().path);
1704 /** 1710 /**
1705 * Creates a directory using a [relativePath] to an existing 1711 * Creates a directory using a [relativePath] to an existing
1706 * [base] directory if that [relativePath] does not already exist. 1712 * [base] directory if that [relativePath] does not already exist.
1707 */ 1713 */
1708 static Directory mkdirRecursive(Path base, Path relativePath) { 1714 static Directory mkdirRecursive(Path base, Path relativePath) {
1709 if (relativePath.isAbsolute) { 1715 if (relativePath.isAbsolute) {
1710 base = new Path('/'); 1716 base = new Path('/');
1711 } 1717 }
1712 Directory dir = new Directory.fromPath(base); 1718 Directory dir = new Directory.fromPath(base);
1713 Expect.isTrue(dir.existsSync(), 1719 assert(dir.existsSync());
1714 "Expected ${dir} to already exist");
1715 var segments = relativePath.segments(); 1720 var segments = relativePath.segments();
1716 for (String segment in segments) { 1721 for (String segment in segments) {
1717 base = base.append(segment); 1722 base = base.append(segment);
1718 if (base.toString() == "/$segment" && 1723 if (base.toString() == "/$segment" &&
1719 segment.length == 2 && 1724 segment.length == 2 &&
1720 segment.endsWith(':')) { 1725 segment.endsWith(':')) {
1721 // Skip the directory creation for a path like "/E:". 1726 // Skip the directory creation for a path like "/E:".
1722 continue; 1727 continue;
1723 } 1728 }
1724 dir = new Directory.fromPath(base); 1729 dir = new Directory.fromPath(base);
1725 if (!dir.existsSync()) { 1730 if (!dir.existsSync()) {
1726 dir.createSync(); 1731 dir.createSync();
1727 } 1732 }
1728 Expect.isTrue(dir.existsSync(), "Failed to create ${dir.path}"); 1733 assert(dir.existsSync());
1729 } 1734 }
1730 return dir; 1735 return dir;
1731 } 1736 }
1732 1737
1733 /** 1738 /**
1734 * Copy a [source] file to a new place. 1739 * Copy a [source] file to a new place.
1735 * Assumes that the directory for [dest] already exists. 1740 * Assumes that the directory for [dest] already exists.
1736 */ 1741 */
1737 static Future copyFile(Path source, Path dest) { 1742 static Future copyFile(Path source, Path dest) {
1738 return new File.fromPath(source).openRead() 1743 return new File.fromPath(source).openRead()
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 * $pass tests are expected to pass 1938 * $pass tests are expected to pass
1934 * $failOk tests are expected to fail that we won't fix 1939 * $failOk tests are expected to fail that we won't fix
1935 * $fail tests are expected to fail that we should fix 1940 * $fail tests are expected to fail that we should fix
1936 * $crash tests are expected to crash that we should fix 1941 * $crash tests are expected to crash that we should fix
1937 * $timeout tests are allowed to timeout 1942 * $timeout tests are allowed to timeout
1938 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1943 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1939 """; 1944 """;
1940 print(report); 1945 print(report);
1941 } 1946 }
1942 } 1947 }
OLDNEW
« tools/test.py ('K') | « tools/testing/dart/multitest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698