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

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

Issue 10228003: Address review comments from CL 10151014. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: typos Created 8 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
« no previous file with comments | « dart/lib/compiler/implementation/dart2js.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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if (shards > 1) { 384 if (shards > 1) {
385 int shard = configuration['shard']; 385 int shard = configuration['shard'];
386 if (testName.hashCode() % shards != shard - 1) { 386 if (testName.hashCode() % shards != shard - 1) {
387 return; 387 return;
388 } 388 }
389 } 389 }
390 390
391 Set<String> expectations = testExpectations.expectations(testName); 391 Set<String> expectations = testExpectations.expectations(testName);
392 if (configuration['report']) { 392 if (configuration['report']) {
393 // Tests with multiple VMOptions are counted more than once. 393 // Tests with multiple VMOptions are counted more than once.
394 for (var dummy in optionsFromFile["vmOptions"]) { 394 for (var dummy in getVmOptions(optionsFromFile)) {
395 if (TestUtils.isBrowserRuntime(configuration['runtime']) && 395 if (TestUtils.isBrowserRuntime(configuration['runtime']) &&
396 optionsFromFile['isMultitest']) { 396 optionsFromFile['isMultitest']) {
397 break; // Browser tests skip multitests. 397 break; // Browser tests skip multitests.
398 } 398 }
399 SummaryReport.add(expectations); 399 SummaryReport.add(expectations);
400 } 400 }
401 } 401 }
402 if (expectations.contains(SKIP)) return; 402 if (expectations.contains(SKIP)) return;
403 403
404 if (TestUtils.isBrowserRuntime(configuration['runtime'])) { 404 if (TestUtils.isBrowserRuntime(configuration['runtime'])) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 440
441 List<Command> makeCommands(TestInformation info, var args) { 441 List<Command> makeCommands(TestInformation info, var args) {
442 if (configuration['compiler'] == 'dart2js') { 442 if (configuration['compiler'] == 'dart2js') {
443 args = new List.from(args); 443 args = new List.from(args);
444 String testPath = 444 String testPath =
445 new File(info.filename).fullPathSync().replaceAll('\\', '/'); 445 new File(info.filename).fullPathSync().replaceAll('\\', '/');
446 Directory tempDir = createOutputDirectory(testPath, ''); 446 Directory tempDir = createOutputDirectory(testPath, '');
447 args.add('--out=${tempDir.path}/out.js'); 447 args.add('--out=${tempDir.path}/out.js');
448 List<Command> commands = <Command>[new Command(shellPath(), args)]; 448 List<Command> commands = <Command>[new Command(shellPath(), args)];
449 if (configuration['runtime'] == 'd8') { 449 if (configuration['runtime'] == 'd8') {
450 var d8 = '${TestUtils.buildDir(configuration)}/' 450 var d8 = TestUtils.d8FileName(configuration);
451 'd8${TestUtils.executableSuffix("d8")}';
452 commands.add(new Command(d8, ['${tempDir.path}/out.js'])); 451 commands.add(new Command(d8, ['${tempDir.path}/out.js']));
453 } 452 }
454 return commands; 453 return commands;
455 } else { 454 } else {
456 return <Command>[new Command(shellPath(), args)]; 455 return <Command>[new Command(shellPath(), args)];
457 } 456 }
458 } 457 }
459 458
460 Function makeTestCaseCreator(Map optionsFromFile) { 459 Function makeTestCaseCreator(Map optionsFromFile) {
461 return (String filename, 460 return (String filename,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { 521 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
523 print('Warning for $filename: Browser tests require #library ' + 522 print('Warning for $filename: Browser tests require #library ' +
524 'in any file that uses #import, #source, or #resource'); 523 'in any file that uses #import, #source, or #resource');
525 } 524 }
526 525
527 final String compiler = configuration['compiler']; 526 final String compiler = configuration['compiler'];
528 final String runtime = configuration['runtime']; 527 final String runtime = configuration['runtime'];
529 final String testPath = 528 final String testPath =
530 new File(filename).fullPathSync().replaceAll('\\', '/'); 529 new File(filename).fullPathSync().replaceAll('\\', '/');
531 530
532 for (var vmOptions in optionsFromFile['vmOptions']) { 531 for (var vmOptions in getVmOptions(optionsFromFile)) {
533 // Create a unique temporary directory for each set of vmOptions. 532 // Create a unique temporary directory for each set of vmOptions.
534 // TODO(dart:429): Replace separate replaceAlls with a RegExp when 533 // TODO(dart:429): Replace separate replaceAlls with a RegExp when
535 // replaceAll(RegExp, String) is implemented. 534 // replaceAll(RegExp, String) is implemented.
536 String optionsName = ''; 535 String optionsName = '';
537 if (optionsFromFile['vmOptions'].length > 1) { 536 if (getVmOptions(optionsFromFile).length > 1) {
538 optionsName = Strings.join(vmOptions, '-').replaceAll('-','') 537 optionsName = Strings.join(vmOptions, '-').replaceAll('-','')
539 .replaceAll('=','') 538 .replaceAll('=','')
540 .replaceAll('/',''); 539 .replaceAll('/','');
541 } 540 }
542 Directory tempDir = createOutputDirectory(testPath, optionsName); 541 Directory tempDir = createOutputDirectory(testPath, optionsName);
543 542
544 String dartWrapperFilename = '${tempDir.path}/test.dart'; 543 String dartWrapperFilename = '${tempDir.path}/test.dart';
545 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; 544 String compiledDartWrapperFilename = '${tempDir.path}/test.js';
546 545
547 String htmlPath = '${tempDir.path}/test.html'; 546 String htmlPath = '${tempDir.path}/test.html';
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 args.add('--error_format'); 851 args.add('--error_format');
853 args.add('machine'); 852 args.add('machine');
854 } 853 }
855 if ((configuration['compiler'] == 'frog') 854 if ((configuration['compiler'] == 'frog')
856 && (configuration['runtime'] == 'none')) { 855 && (configuration['runtime'] == 'none')) {
857 args.add('--compile-only'); 856 args.add('--compile-only');
858 } 857 }
859 858
860 bool isMultitest = optionsFromFile["isMultitest"]; 859 bool isMultitest = optionsFromFile["isMultitest"];
861 List<String> dartOptions = optionsFromFile["dartOptions"]; 860 List<String> dartOptions = optionsFromFile["dartOptions"];
862 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; 861 List<List<String>> vmOptionsList = getVmOptions(optionsFromFile);
863 if (configuration['compiler'] == 'dart2js') {
864 vmOptionsList = [[]];
865 }
866 Expect.isTrue(!isMultitest || dartOptions == null); 862 Expect.isTrue(!isMultitest || dartOptions == null);
867 if (dartOptions == null) { 863 if (dartOptions == null) {
868 args.add(filename); 864 args.add(filename);
869 } else { 865 } else {
870 var executable_name = dartOptions[0]; 866 var executable_name = dartOptions[0];
871 // TODO(ager): Get rid of this hack when the runtime checkout goes away. 867 // TODO(ager): Get rid of this hack when the runtime checkout goes away.
872 var file = new File(executable_name); 868 var file = new File(executable_name);
873 if (!file.existsSync()) { 869 if (!file.existsSync()) {
874 executable_name = '../$executable_name'; 870 executable_name = '../$executable_name';
875 Expect.isTrue(new File(executable_name).existsSync()); 871 Expect.isTrue(new File(executable_name).existsSync());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 "otherScripts": otherScripts, 985 "otherScripts": otherScripts,
990 "isMultitest": isMultitest, 986 "isMultitest": isMultitest,
991 "containsLeadingHash": containsLeadingHash, 987 "containsLeadingHash": containsLeadingHash,
992 "isolateStubs": isolateStubs, 988 "isolateStubs": isolateStubs,
993 "containsDomImport": containsDomImport, 989 "containsDomImport": containsDomImport,
994 "isLibraryDefinition": isLibraryDefinition, 990 "isLibraryDefinition": isLibraryDefinition,
995 "containsSourceOrImport": containsSourceOrImport, 991 "containsSourceOrImport": containsSourceOrImport,
996 "numStaticTypeAnnotations": numStaticTypeAnnotations, 992 "numStaticTypeAnnotations": numStaticTypeAnnotations,
997 "numCompileTimeAnnotations": numCompileTimeAnnotations}; 993 "numCompileTimeAnnotations": numCompileTimeAnnotations};
998 } 994 }
995
996 List<List<String>> getVmOptions(Map optionsFromFile) {
997 if (configuration['compiler'] == 'dart2js') {
998 return [[]];
999 } else {
1000 return optionsFromFile['vmOptions'];
1001 }
1002 }
999 } 1003 }
1000 1004
1001 1005
1002 class DartcCompilationTestSuite extends StandardTestSuite { 1006 class DartcCompilationTestSuite extends StandardTestSuite {
1003 List<String> _testDirs; 1007 List<String> _testDirs;
1004 int activityCount = 0; 1008 int activityCount = 0;
1005 1009
1006 DartcCompilationTestSuite(Map configuration, 1010 DartcCompilationTestSuite(Map configuration,
1007 String suiteName, 1011 String suiteName,
1008 String directoryPath, 1012 String directoryPath,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 default: 1254 default:
1251 throw "Unknown compiler for: ${configuration['compiler']}"; 1255 throw "Unknown compiler for: ${configuration['compiler']}";
1252 } 1256 }
1253 } 1257 }
1254 1258
1255 static String dartShellFileName(Map configuration) { 1259 static String dartShellFileName(Map configuration) {
1256 var name = configuration['dart']; 1260 var name = configuration['dart'];
1257 if (name == '') { 1261 if (name == '') {
1258 name = '${buildDir(configuration)}/${executableName(configuration)}'; 1262 name = '${buildDir(configuration)}/${executableName(configuration)}';
1259 } 1263 }
1260 if (!(new File(name)).existsSync() && !configuration['list']) { 1264 ensureExists(name, configuration);
1261 throw "Executable '$name' does not exist"; 1265 return name;
1266 }
1267
1268 static String d8FileName(Map configuration) {
1269 var suffix = executableSuffix('d8');
1270 var d8 = '${buildDir(configuration)}/d8$suffix';
1271 ensureExists(d8, configuration);
1272 return d8;
1273 }
1274
1275 static void ensureExists(String filename, Map configuration) {
1276 if (!configuration['list'] && !(new File(filename).existsSync())) {
1277 throw "Executable '$filename' does not exist";
1262 } 1278 }
1263 return name;
1264 } 1279 }
1265 1280
1266 static String compilerPath(Map configuration) { 1281 static String compilerPath(Map configuration) {
1267 if (configuration['compiler'] == 'none') { 1282 if (configuration['compiler'] == 'none') {
1268 return null; // No separate compiler for dartium tests. 1283 return null; // No separate compiler for dartium tests.
1269 } 1284 }
1270 var name = configuration['frog']; 1285 var name = configuration['frog'];
1271 if (name == '') { 1286 if (name == '') {
1272 name = '${buildDir(configuration)}/${compilerName(configuration)}'; 1287 name = '${buildDir(configuration)}/${compilerName(configuration)}';
1273 } 1288 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 * $noCrash tests are expected to be flaky but not crash 1386 * $noCrash tests are expected to be flaky but not crash
1372 * $pass tests are expected to pass 1387 * $pass tests are expected to pass
1373 * $failOk tests are expected to fail that we won't fix 1388 * $failOk tests are expected to fail that we won't fix
1374 * $fail tests are expected to fail that we should fix 1389 * $fail tests are expected to fail that we should fix
1375 * $crash tests are expected to crash that we should fix 1390 * $crash tests are expected to crash that we should fix
1376 * $timeout tests are allowed to timeout 1391 * $timeout tests are allowed to timeout
1377 """; 1392 """;
1378 print(report); 1393 print(report);
1379 } 1394 }
1380 } 1395 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698