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

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

Issue 11035027: Add in-process http server to the dart test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows Created 8 years, 2 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 isNegative = true; 438 isNegative = true;
439 } 439 }
440 } 440 }
441 441
442 var commonArguments = commonArgumentsFromFile(info.filePath, 442 var commonArguments = commonArgumentsFromFile(info.filePath,
443 info.optionsFromFile); 443 info.optionsFromFile);
444 444
445 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); 445 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile);
446 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); 446 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList");
447 447
448 // Check for an "ExtraCommand" comment from the file, and generate
449 // a command for it, if needed.
450 var optionsFromFile = info.optionsFromFile;
451 var commands = [];
452 var command = optionsFromFile['extraCommand'];
453 var args = optionsFromFile['extraCommandArgs'];
454 addExtraCommand(command, args, commands);
455
456 List _append(list1,list2) => []..addAll(list1)..addAll(list2); 448 List _append(list1,list2) => []..addAll(list1)..addAll(list2);
ahe 2012/10/04 10:06:43 Remove this.
Mads Ager (google) 2012/10/04 10:21:51 Thanks! Done.
457 449
458 for (var vmOptions in vmOptionsList) { 450 for (var vmOptions in vmOptionsList) {
459 doTest(new TestCase('$suiteName/$testName', 451 doTest(new TestCase('$suiteName/$testName',
460 _append(commands, 452 makeCommands(info, vmOptions, commonArguments),
461 makeCommands(info, vmOptions, commonArguments)),
462 configuration, 453 configuration,
463 completeHandler, 454 completeHandler,
464 expectations, 455 expectations,
465 isNegative: isNegative, 456 isNegative: isNegative,
466 info: info)); 457 info: info));
467 } 458 }
468 } 459 }
469 460
470 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { 461 List<Command> makeCommands(TestInformation info, var vmOptions, var args) {
471 switch (configuration['compiler']) { 462 switch (configuration['compiler']) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 case 'dartc': 507 case 'dartc':
517 var arguments = new List.from(vmOptions); 508 var arguments = new List.from(vmOptions);
518 arguments.addAll(args); 509 arguments.addAll(args);
519 return <Command>[new Command(shellPath(), arguments)]; 510 return <Command>[new Command(shellPath(), arguments)];
520 511
521 default: 512 default:
522 throw 'Unknown compiler ${configuration["compiler"]}'; 513 throw 'Unknown compiler ${configuration["compiler"]}';
523 } 514 }
524 } 515 }
525 516
526 void addExtraCommand(String command, List<String> arguments, List commands) {
527 if (command == null) return;
528 // As a special case, a command of "dart" should run with the
529 // dart VM that we are testing.
530 if (command == 'dart') {
531 command = TestUtils.vmFileName(configuration);
532 }
533 arguments =
534 arguments.map((arg)=>arg.replaceAll(r"$dartDir", dartDir.toString()));
535 commands.add(new Command(command, arguments));
536 }
537
538 CreateTest makeTestCaseCreator(Map optionsFromFile) { 517 CreateTest makeTestCaseCreator(Map optionsFromFile) {
539 return (Path filePath, 518 return (Path filePath,
540 bool hasCompileError, 519 bool hasCompileError,
541 bool hasRuntimeError, 520 bool hasRuntimeError,
542 {bool isNegativeIfChecked: false, 521 {bool isNegativeIfChecked: false,
543 bool hasFatalTypeErrors: false, 522 bool hasFatalTypeErrors: false,
544 Set<String> multitestOutcome: null}) { 523 Set<String> multitestOutcome: null}) {
545 // Cache the test information for each test case. 524 // Cache the test information for each test case.
546 var info = new TestInformation(filePath, 525 var info = new TestInformation(filePath,
547 optionsFromFile, 526 optionsFromFile,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 Path namePath = new Path(name); 685 Path namePath = new Path(name);
707 Expect.equals(namePath.extension, 'dart'); 686 Expect.equals(namePath.extension, 'dart');
708 String baseName = namePath.filenameWithoutExtension; 687 String baseName = namePath.filenameWithoutExtension;
709 Path fromPath = filePath.directoryPath.join(namePath); 688 Path fromPath = filePath.directoryPath.join(namePath);
710 commands.add(_compileCommand( 689 commands.add(_compileCommand(
711 fromPath.toNativePath(), '$tempDir/$baseName.js', 690 fromPath.toNativePath(), '$tempDir/$baseName.js',
712 compiler, tempDir, vmOptions)); 691 compiler, tempDir, vmOptions));
713 } 692 }
714 } 693 }
715 694
716 var extraCommand = optionsFromFile['extraCommand'];
717 var extraArgs = optionsFromFile['extraCommandArgs'];
718 addExtraCommand(extraCommand, extraArgs, commands);
719
720 // Construct the command that executes the browser test 695 // Construct the command that executes the browser test
721 List<String> args; 696 List<String> args;
722 if (runtime == 'ie' || runtime == 'ff' || runtime == 'chrome' || 697 if (runtime == 'ie' || runtime == 'ff' || runtime == 'chrome' ||
723 runtime == 'safari' || runtime == 'opera' || runtime == 'dartium') { 698 runtime == 'safari' || runtime == 'opera' || runtime == 'dartium') {
724 args = [dartDir.append('tools/testing/run_selenium.py').toNativePath(), 699 args = [dartDir.append('tools/testing/run_selenium.py').toNativePath(),
725 '--browser=$runtime', 700 '--browser=$runtime',
726 '--timeout=${configuration["timeout"] - 2}', 701 '--timeout=${configuration["timeout"] - 2}',
727 '--out=$htmlPath']; 702 '--out=$htmlPath'];
728 if (runtime == 'dartium') { 703 if (runtime == 'dartium') {
729 args.add('--executable=$dartiumFilename'); 704 args.add('--executable=$dartiumFilename');
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 RegExp staticCleanRegExp = const RegExp(r"// @static-clean"); 963 RegExp staticCleanRegExp = const RegExp(r"// @static-clean");
989 RegExp leadingHashRegExp = const RegExp(r"^#", multiLine: true); 964 RegExp leadingHashRegExp = const RegExp(r"^#", multiLine: true);
990 RegExp isolateStubsRegExp = const RegExp(r"// IsolateStubs=(.*)"); 965 RegExp isolateStubsRegExp = const RegExp(r"// IsolateStubs=(.*)");
991 RegExp domImportRegExp = 966 RegExp domImportRegExp =
992 const RegExp(r"^#import.*(dart:(dom|html)|html\.dart).*\)", 967 const RegExp(r"^#import.*(dart:(dom|html)|html\.dart).*\)",
993 multiLine: true); 968 multiLine: true);
994 RegExp libraryDefinitionRegExp = 969 RegExp libraryDefinitionRegExp =
995 const RegExp(r"^#library\(", multiLine: true); 970 const RegExp(r"^#library\(", multiLine: true);
996 RegExp sourceOrImportRegExp = 971 RegExp sourceOrImportRegExp =
997 const RegExp(r"^#(source|import|resource)\(", multiLine: true); 972 const RegExp(r"^#(source|import|resource)\(", multiLine: true);
998 RegExp extraCommandRegExp =
999 const RegExp(r"// ExtraCommand=(.*)", multiLine: true);
1000 RegExp extraArgsRegExp =
1001 const RegExp(r"// ExtraCommandArgs=(.*)", multiLine: true);
1002 973
1003 // Read the entire file into a byte buffer and transform it to a 974 // Read the entire file into a byte buffer and transform it to a
1004 // String. This will treat the file as ascii but the only parts 975 // String. This will treat the file as ascii but the only parts
1005 // we are interested in will be ascii in any case. 976 // we are interested in will be ascii in any case.
1006 RandomAccessFile file = new File.fromPath(filePath).openSync(FileMode.READ); 977 RandomAccessFile file = new File.fromPath(filePath).openSync(FileMode.READ);
1007 List chars = new List(file.lengthSync()); 978 List chars = new List(file.lengthSync());
1008 var offset = 0; 979 var offset = 0;
1009 while (offset != chars.length) { 980 while (offset != chars.length) {
1010 offset += file.readListSync(chars, offset, chars.length - offset); 981 offset += file.readListSync(chars, offset, chars.length - offset);
1011 } 982 }
(...skipping 16 matching lines...) Expand all
1028 999
1029 matches = dartOptionsRegExp.allMatches(contents); 1000 matches = dartOptionsRegExp.allMatches(contents);
1030 for (var match in matches) { 1001 for (var match in matches) {
1031 if (dartOptions != null) { 1002 if (dartOptions != null) {
1032 throw new Exception( 1003 throw new Exception(
1033 'More than one "// DartOptions=" line in test $filePath'); 1004 'More than one "// DartOptions=" line in test $filePath');
1034 } 1005 }
1035 dartOptions = match[1].split(' ').filter((e) => e != ''); 1006 dartOptions = match[1].split(' ').filter((e) => e != '');
1036 } 1007 }
1037 1008
1038 var match = extraCommandRegExp.firstMatch(contents);
1039 var extraCommand = (match != null) ? match.group(1) : null;
1040 match = extraArgsRegExp.firstMatch(contents);
1041 var extraCommandArgs = (match != null) ? match.group(1).split(' ') : [];
1042
1043 matches = staticCleanRegExp.allMatches(contents); 1009 matches = staticCleanRegExp.allMatches(contents);
1044 for (var match in matches) { 1010 for (var match in matches) {
1045 if (isStaticClean) { 1011 if (isStaticClean) {
1046 throw new Exception( 1012 throw new Exception(
1047 'More than one "// @static-clean=" line in test $filePath'); 1013 'More than one "// @static-clean=" line in test $filePath');
1048 } 1014 }
1049 isStaticClean = true; 1015 isStaticClean = true;
1050 } 1016 }
1051 1017
1052 List<String> otherScripts = new List<String>(); 1018 List<String> otherScripts = new List<String>();
(...skipping 24 matching lines...) Expand all
1077 "hasRuntimeError": hasRuntimeError, 1043 "hasRuntimeError": hasRuntimeError,
1078 "isStaticClean" : isStaticClean, 1044 "isStaticClean" : isStaticClean,
1079 "otherScripts": otherScripts, 1045 "otherScripts": otherScripts,
1080 "isMultitest": isMultitest, 1046 "isMultitest": isMultitest,
1081 "containsLeadingHash": containsLeadingHash, 1047 "containsLeadingHash": containsLeadingHash,
1082 "isolateStubs": isolateStubs, 1048 "isolateStubs": isolateStubs,
1083 "containsDomImport": containsDomImport, 1049 "containsDomImport": containsDomImport,
1084 "isLibraryDefinition": isLibraryDefinition, 1050 "isLibraryDefinition": isLibraryDefinition,
1085 "containsSourceOrImport": containsSourceOrImport, 1051 "containsSourceOrImport": containsSourceOrImport,
1086 "numStaticTypeAnnotations": numStaticTypeAnnotations, 1052 "numStaticTypeAnnotations": numStaticTypeAnnotations,
1087 "numCompileTimeAnnotations": numCompileTimeAnnotations, 1053 "numCompileTimeAnnotations": numCompileTimeAnnotations };
1088 "extraCommand": extraCommand,
1089 "extraCommandArgs": extraCommandArgs};
1090 } 1054 }
1091 1055
1092 List<List<String>> getVmOptions(Map optionsFromFile) { 1056 List<List<String>> getVmOptions(Map optionsFromFile) {
1093 bool needsVmOptions = Contains(configuration['compiler'], 1057 bool needsVmOptions = Contains(configuration['compiler'],
1094 const ['none', 'dart2dart', 'dartc']) && 1058 const ['none', 'dart2dart', 'dartc']) &&
1095 Contains(configuration['runtime'], 1059 Contains(configuration['runtime'],
1096 const ['none', 'vm', 'drt', 'dartium']); 1060 const ['none', 'vm', 'drt', 'dartium']);
1097 if (!needsVmOptions) return [[]]; 1061 if (!needsVmOptions) return [[]];
1098 return optionsFromFile['vmOptions']; 1062 return optionsFromFile['vmOptions'];
1099 } 1063 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 * $noCrash tests are expected to be flaky but not crash 1455 * $noCrash tests are expected to be flaky but not crash
1492 * $pass tests are expected to pass 1456 * $pass tests are expected to pass
1493 * $failOk tests are expected to fail that we won't fix 1457 * $failOk tests are expected to fail that we won't fix
1494 * $fail tests are expected to fail that we should fix 1458 * $fail tests are expected to fail that we should fix
1495 * $crash tests are expected to crash that we should fix 1459 * $crash tests are expected to crash that we should fix
1496 * $timeout tests are allowed to timeout 1460 * $timeout tests are allowed to timeout
1497 """; 1461 """;
1498 print(report); 1462 print(report);
1499 } 1463 }
1500 } 1464 }
OLDNEW
« tools/testing/dart/http_server.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698