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

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

Issue 10959002: Read locales over http in the browser (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« pkg/intl/test/start_web_server.dart ('K') | « pkg/pkg.status ('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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } else if (info.hasRuntimeErrors) { 421 } else if (info.hasRuntimeErrors) {
422 isNegative = false; 422 isNegative = false;
423 } 423 }
424 } 424 }
425 425
426 var commonArguments = commonArgumentsFromFile(info.filePath, 426 var commonArguments = commonArgumentsFromFile(info.filePath,
427 info.optionsFromFile); 427 info.optionsFromFile);
428 428
429 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); 429 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile);
430 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); 430 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList");
431
432 // Check for an "ExtraCommand" comment from the file, and generate
433 // a command for it, if needed.
434 var optionsFromFile = info.optionsFromFile;
435 var commands = [];
436 var command = optionsFromFile['extraCommand'];
437 var args = optionsFromFile['extraCommandArgs'];
438 if (command != null) {
439 commands.add(new Command(command, args));
440 }
441
442 List _append(list1,list2) => []..addAll(list1)..addAll(list2);
Emily Fortuna 2012/09/20 23:07:19 woohoo! real-life use of method cascades! Is ther
Alan Knight 2012/09/20 23:29:59 It's called in one place, but inside a loop, so I
443
431 for (var vmOptions in vmOptionsList) { 444 for (var vmOptions in vmOptionsList) {
432 doTest(new TestCase('$suiteName/$testName', 445 doTest(new TestCase('$suiteName/$testName',
433 makeCommands(info, vmOptions, commonArguments), 446 _append(commands,
447 makeCommands(info, vmOptions, commonArguments)),
434 configuration, 448 configuration,
435 completeHandler, 449 completeHandler,
436 expectations, 450 expectations,
437 isNegative, 451 isNegative,
438 info)); 452 info));
439 } 453 }
440 } 454 }
441 455
442 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { 456 List<Command> makeCommands(TestInformation info, var vmOptions, var args) {
443 switch (configuration['compiler']) { 457 switch (configuration['compiler']) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 Path namePath = new Path(name); 672 Path namePath = new Path(name);
659 Expect.equals(namePath.extension, 'dart'); 673 Expect.equals(namePath.extension, 'dart');
660 String baseName = namePath.filenameWithoutExtension; 674 String baseName = namePath.filenameWithoutExtension;
661 Path fromPath = filePath.directoryPath.join(namePath); 675 Path fromPath = filePath.directoryPath.join(namePath);
662 commands.add(_compileCommand( 676 commands.add(_compileCommand(
663 fromPath.toNativePath(), '$tempDir/$baseName.js', 677 fromPath.toNativePath(), '$tempDir/$baseName.js',
664 compiler, tempDir, vmOptions)); 678 compiler, tempDir, vmOptions));
665 } 679 }
666 } 680 }
667 681
682 var extraCommand = optionsFromFile['extraCommand'];
683 if (extraCommand != null) {
684 var args = optionsFromFile['extraCommandArgs'];
685 // As a special case, a command of "dart" should run with the same
686 // dart executable that we are using.
687 if (extraCommand == 'dart') {
688 extraCommand = new Options().executable;
689 }
690 commands.add(new Command(extraCommand, args));
691 }
692
668 // Construct the command that executes the browser test 693 // Construct the command that executes the browser test
669 List<String> args; 694 List<String> args;
670 if (runtime == 'ie' || runtime == 'ff' || runtime == 'chrome' || 695 if (runtime == 'ie' || runtime == 'ff' || runtime == 'chrome' ||
671 runtime == 'safari' || runtime == 'opera' || runtime == 'dartium') { 696 runtime == 'safari' || runtime == 'opera' || runtime == 'dartium') {
672 args = [dartDir.append('tools/testing/run_selenium.py').toNativePath(), 697 args = [dartDir.append('tools/testing/run_selenium.py').toNativePath(),
673 '--browser=$runtime', 698 '--browser=$runtime',
674 '--timeout=${configuration["timeout"] - 2}', 699 '--timeout=${configuration["timeout"] - 2}',
675 '--out=$htmlPath']; 700 '--out=$htmlPath'];
676 if (runtime == 'dartium') { 701 if (runtime == 'dartium') {
677 args.add('--executable=$dartiumFilename'); 702 args.add('--executable=$dartiumFilename');
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 RegExp staticCleanRegExp = const RegExp(@"// @static-clean"); 960 RegExp staticCleanRegExp = const RegExp(@"// @static-clean");
936 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); 961 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true);
937 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); 962 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)");
938 RegExp domImportRegExp = 963 RegExp domImportRegExp =
939 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", 964 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)",
940 multiLine: true); 965 multiLine: true);
941 RegExp libraryDefinitionRegExp = 966 RegExp libraryDefinitionRegExp =
942 const RegExp(@"^#library\(", multiLine: true); 967 const RegExp(@"^#library\(", multiLine: true);
943 RegExp sourceOrImportRegExp = 968 RegExp sourceOrImportRegExp =
944 const RegExp(@"^#(source|import|resource)\(", multiLine: true); 969 const RegExp(@"^#(source|import|resource)\(", multiLine: true);
970 RegExp extraCommandRegExp =
971 const RegExp(@"// ExtraCommand=(.*)", multiLine: true);
972 RegExp extraArgsRegExp =
973 const RegExp(@"// ExtraCommandArgs=(.*)", multiLine: true);
945 974
946 // Read the entire file into a byte buffer and transform it to a 975 // Read the entire file into a byte buffer and transform it to a
947 // String. This will treat the file as ascii but the only parts 976 // String. This will treat the file as ascii but the only parts
948 // we are interested in will be ascii in any case. 977 // we are interested in will be ascii in any case.
949 RandomAccessFile file = new File.fromPath(filePath).openSync(FileMode.READ); 978 RandomAccessFile file = new File.fromPath(filePath).openSync(FileMode.READ);
950 List chars = new List(file.lengthSync()); 979 List chars = new List(file.lengthSync());
951 var offset = 0; 980 var offset = 0;
952 while (offset != chars.length) { 981 while (offset != chars.length) {
953 offset += file.readListSync(chars, offset, chars.length - offset); 982 offset += file.readListSync(chars, offset, chars.length - offset);
954 } 983 }
(...skipping 15 matching lines...) Expand all
970 999
971 matches = dartOptionsRegExp.allMatches(contents); 1000 matches = dartOptionsRegExp.allMatches(contents);
972 for (var match in matches) { 1001 for (var match in matches) {
973 if (dartOptions != null) { 1002 if (dartOptions != null) {
974 throw new Exception( 1003 throw new Exception(
975 'More than one "// DartOptions=" line in test $filePath'); 1004 'More than one "// DartOptions=" line in test $filePath');
976 } 1005 }
977 dartOptions = match[1].split(' ').filter((e) => e != ''); 1006 dartOptions = match[1].split(' ').filter((e) => e != '');
978 } 1007 }
979 1008
1009 var match = extraCommandRegExp.firstMatch(contents);
1010 var extraCommand = (match != null) ? match.group(1) : null;
1011 match = extraArgsRegExp.firstMatch(contents);
1012 var extraCommandArgs = (match != null) ? match.group(1).split(' ') : [];
1013
980 matches = staticCleanRegExp.allMatches(contents); 1014 matches = staticCleanRegExp.allMatches(contents);
981 for (var match in matches) { 1015 for (var match in matches) {
982 if (isStaticClean) { 1016 if (isStaticClean) {
983 throw new Exception( 1017 throw new Exception(
984 'More than one "// @static-clean=" line in test $filePath'); 1018 'More than one "// @static-clean=" line in test $filePath');
985 } 1019 }
986 isStaticClean = true; 1020 isStaticClean = true;
987 } 1021 }
988 1022
989 List<String> otherScripts = new List<String>(); 1023 List<String> otherScripts = new List<String>();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 "isNegative": isNegative, 1055 "isNegative": isNegative,
1022 "isStaticClean" : isStaticClean, 1056 "isStaticClean" : isStaticClean,
1023 "otherScripts": otherScripts, 1057 "otherScripts": otherScripts,
1024 "isMultitest": isMultitest, 1058 "isMultitest": isMultitest,
1025 "containsLeadingHash": containsLeadingHash, 1059 "containsLeadingHash": containsLeadingHash,
1026 "isolateStubs": isolateStubs, 1060 "isolateStubs": isolateStubs,
1027 "containsDomImport": containsDomImport, 1061 "containsDomImport": containsDomImport,
1028 "isLibraryDefinition": isLibraryDefinition, 1062 "isLibraryDefinition": isLibraryDefinition,
1029 "containsSourceOrImport": containsSourceOrImport, 1063 "containsSourceOrImport": containsSourceOrImport,
1030 "numStaticTypeAnnotations": numStaticTypeAnnotations, 1064 "numStaticTypeAnnotations": numStaticTypeAnnotations,
1031 "numCompileTimeAnnotations": numCompileTimeAnnotations}; 1065 "numCompileTimeAnnotations": numCompileTimeAnnotations,
1066 "extraCommand": extraCommand,
1067 "extraCommandArgs": extraCommandArgs};
1032 } 1068 }
1033 1069
1034 List<List<String>> getVmOptions(Map optionsFromFile) { 1070 List<List<String>> getVmOptions(Map optionsFromFile) {
1035 bool needsVmOptions = Contains(configuration['compiler'], 1071 bool needsVmOptions = Contains(configuration['compiler'],
1036 const ['none', 'dart2dart', 'dartc']) && 1072 const ['none', 'dart2dart', 'dartc']) &&
1037 Contains(configuration['runtime'], 1073 Contains(configuration['runtime'],
1038 const ['none', 'vm', 'drt', 'dartium']); 1074 const ['none', 'vm', 'drt', 'dartium']);
1039 if (!needsVmOptions) return [[]]; 1075 if (!needsVmOptions) return [[]];
1040 return optionsFromFile['vmOptions']; 1076 return optionsFromFile['vmOptions'];
1041 } 1077 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 * $noCrash tests are expected to be flaky but not crash 1460 * $noCrash tests are expected to be flaky but not crash
1425 * $pass tests are expected to pass 1461 * $pass tests are expected to pass
1426 * $failOk tests are expected to fail that we won't fix 1462 * $failOk tests are expected to fail that we won't fix
1427 * $fail tests are expected to fail that we should fix 1463 * $fail tests are expected to fail that we should fix
1428 * $crash tests are expected to crash that we should fix 1464 * $crash tests are expected to crash that we should fix
1429 * $timeout tests are allowed to timeout 1465 * $timeout tests are allowed to timeout
1430 """; 1466 """;
1431 print(report); 1467 print(report);
1432 } 1468 }
1433 } 1469 }
OLDNEW
« pkg/intl/test/start_web_server.dart ('K') | « pkg/pkg.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698