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

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

Issue 770633003: tools: removed unused members, tiny cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « tools/testing/dart/test_runner.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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 var sdk = configuration['use_sdk'] ? '-sdk' : ''; 355 var sdk = configuration['use_sdk'] ? '-sdk' : '';
356 var packages = configuration['use_public_packages'] 356 var packages = configuration['use_public_packages']
357 ? '-public_packages' : ''; 357 ? '-public_packages' : '';
358 var dirName = "${configuration['compiler']}" 358 var dirName = "${configuration['compiler']}"
359 "$checked$minified$csp$packages$sdk"; 359 "$checked$minified$csp$packages$sdk";
360 return createGeneratedTestDirectoryHelper( 360 return createGeneratedTestDirectoryHelper(
361 "compilations", dirName, testPath, ""); 361 "compilations", dirName, testPath, "");
362 } 362 }
363 363
364 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { 364 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) {
365 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir);
366 var sdk = configuration['use_sdk'] ? '-sdk' : ''; 365 var sdk = configuration['use_sdk'] ? '-sdk' : '';
367 var pkg = configuration['use_public_packages'] 366 var pkg = configuration['use_public_packages']
368 ? 'public_packages' : 'repo_packages'; 367 ? 'public_packages' : 'repo_packages';
369 return createGeneratedTestDirectoryHelper( 368 return createGeneratedTestDirectoryHelper(
370 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, ""); 369 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, "");
371 } 370 }
372 371
373 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { 372 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) {
374 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir);
375 var pkg = configuration['use_public_packages'] 373 var pkg = configuration['use_public_packages']
376 ? 'public_packages' : 'repo_packages'; 374 ? 'public_packages' : 'repo_packages';
377 return createGeneratedTestDirectoryHelper( 375 return createGeneratedTestDirectoryHelper(
378 "pub_package_builds", pkg, directoryOfPubspecYaml, ""); 376 "pub_package_builds", pkg, directoryOfPubspecYaml, "");
379 } 377 }
380 378
381 /** 379 /**
382 * Helper function for discovering the packages in the dart repository. 380 * Helper function for discovering the packages in the dart repository.
383 */ 381 */
384 Future<List> listDir(Path path, Function isValid) { 382 Future<List> listDir(Path path, Function isValid) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return new Future.value(null); 767 return new Future.value(null);
770 } else { 768 } else {
771 var group = new FutureGroup(); 769 var group = new FutureGroup();
772 enqueueDirectory(dir, group); 770 enqueueDirectory(dir, group);
773 return group.future; 771 return group.future;
774 } 772 }
775 }); 773 });
776 } 774 }
777 775
778 void enqueueDirectory(Directory dir, FutureGroup group) { 776 void enqueueDirectory(Directory dir, FutureGroup group) {
779 var listCompleter = new Completer();
780 group.add(listCompleter.future);
781
782 var lister = dir.list(recursive: listRecursively) 777 var lister = dir.list(recursive: listRecursively)
783 .listen((FileSystemEntity fse) { 778 .forEach((FileSystemEntity fse) {
ricow1 2014/12/04 13:14:04 .where((fse) => fse is File) .forEach((fse) => enq
784 if (fse is File) enqueueFile(fse.path, group); 779 if (fse is File) enqueueFile(fse.path, group);
785 }, 780 });
786 onDone: listCompleter.complete); 781 group.add(lister);
787 } 782 }
788 783
789 void enqueueFile(String filename, FutureGroup group) { 784 void enqueueFile(String filename, FutureGroup group) {
790 if (isHtmlTestFile(filename)) { 785 if (isHtmlTestFile(filename)) {
791 var info = htmlTest.getInformation(filename); 786 var info = htmlTest.getInformation(filename);
792 if (info == null) { 787 if (info == null) {
793 DebugLogger.error( 788 DebugLogger.error(
794 "HtmlTest $filename does not contain required annotations"); 789 "HtmlTest $filename does not contain required annotations");
795 return; 790 return;
796 } 791 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 port: serverPort, 1115 port: serverPort,
1121 path: pathComponent, 1116 path: pathComponent,
1122 queryParameters: parameters); 1117 queryParameters: parameters);
1123 } 1118 }
1124 1119
1125 void _createWrapperFile(String dartWrapperFilename, 1120 void _createWrapperFile(String dartWrapperFilename,
1126 Path localDartLibraryFilename) { 1121 Path localDartLibraryFilename) {
1127 File file = new File(dartWrapperFilename); 1122 File file = new File(dartWrapperFilename);
1128 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); 1123 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE);
1129 1124
1130 var usePackageImport = localDartLibraryFilename.segments().contains("pkg");
1131 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename); 1125 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename);
1132 var generatedSource = dartTestWrapper(libraryPathComponent); 1126 var generatedSource = dartTestWrapper(libraryPathComponent);
1133 dartWrapper.writeStringSync(generatedSource); 1127 dartWrapper.writeStringSync(generatedSource);
1134 dartWrapper.closeSync(); 1128 dartWrapper.closeSync();
1135 } 1129 }
1136 1130
1137 /** 1131 /**
1138 * The [StandardTestSuite] has support for tests that 1132 * The [StandardTestSuite] has support for tests that
1139 * compile a test from Dart to JavaScript, and then run the resulting 1133 * compile a test from Dart to JavaScript, and then run the resulting
1140 * JavaScript. This function creates a working directory to hold the 1134 * JavaScript. This function creates a working directory to hold the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 final String compilationTempDir = 1187 final String compilationTempDir =
1194 createCompilationOutputDirectory(info.filePath); 1188 createCompilationOutputDirectory(info.filePath);
1195 1189
1196 String dartWrapperFilename = '$tempDir/test.dart'; 1190 String dartWrapperFilename = '$tempDir/test.dart';
1197 String compiledDartWrapperFilename = '$compilationTempDir/test.js'; 1191 String compiledDartWrapperFilename = '$compilationTempDir/test.js';
1198 1192
1199 String content = null; 1193 String content = null;
1200 Path dir = filePath.directoryPath; 1194 Path dir = filePath.directoryPath;
1201 String nameNoExt = filePath.filenameWithoutExtension; 1195 String nameNoExt = filePath.filenameWithoutExtension;
1202 1196
1203 Path pngPath = dir.append('$nameNoExt.png');
1204 Path txtPath = dir.append('$nameNoExt.txt');
1205 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath(); 1197 String customHtmlPath = dir.append('$nameNoExt.html').toNativePath();
1206 File customHtml = new File(customHtmlPath); 1198 File customHtml = new File(customHtmlPath);
1207 1199
1208 // Construct the command(s) that compile all the inputs needed by the 1200 // Construct the command(s) that compile all the inputs needed by the
1209 // browser test. For running Dart in DRT, this will be noop commands. 1201 // browser test. For running Dart in DRT, this will be noop commands.
1210 List<Command> commands = []..addAll(baseCommands); 1202 List<Command> commands = []..addAll(baseCommands);
1211 1203
1212 // Use existing HTML document if available. 1204 // Use existing HTML document if available.
1213 String htmlPath; 1205 String htmlPath;
1214 if (customHtml.existsSync()) { 1206 if (customHtml.existsSync()) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 List<String> subtestNames = 1308 List<String> subtestNames =
1317 multitest ? info.optionsFromFile['subtestNames'] : [null]; 1309 multitest ? info.optionsFromFile['subtestNames'] : [null];
1318 for (String subtestName in subtestNames) { 1310 for (String subtestName in subtestNames) {
1319 // Construct the command that executes the browser test 1311 // Construct the command that executes the browser test
1320 List<Command> commandSet = new List<Command>.from(commands); 1312 List<Command> commandSet = new List<Command>.from(commands);
1321 1313
1322 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); 1314 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath));
1323 var fullHtmlPath = 1315 var fullHtmlPath =
1324 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); 1316 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString();
1325 1317
1326 List<String> args = <String>[];
1327
1328 if (runtime == "drt") { 1318 if (runtime == "drt") {
1329 var dartFlags = []; 1319 var dartFlags = [];
1330 var contentShellOptions = []; 1320 var contentShellOptions = [];
1331 1321
1332 contentShellOptions.add('--no-timeout'); 1322 contentShellOptions.add('--no-timeout');
1333 contentShellOptions.add('--dump-render-tree'); 1323 contentShellOptions.add('--dump-render-tree');
1334 1324
1335 if (compiler == 'none' || compiler == 'dart2dart') { 1325 if (compiler == 'none' || compiler == 'dart2dart') {
1336 dartFlags.add('--ignore-unrecognized-flags'); 1326 dartFlags.add('--ignore-unrecognized-flags');
1337 if (configuration["checked"]) { 1327 if (configuration["checked"]) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 isNegative(info), 1439 isNegative(info),
1450 fullHtmlPath); 1440 fullHtmlPath);
1451 enqueueNewTestCase(testCase); 1441 enqueueNewTestCase(testCase);
1452 return; 1442 return;
1453 } 1443 }
1454 1444
1455 /** Helper to create a compilation command for a single input file. */ 1445 /** Helper to create a compilation command for a single input file. */
1456 Command _compileCommand(String inputFile, String outputFile, 1446 Command _compileCommand(String inputFile, String outputFile,
1457 String compiler, String dir, optionsFromFile) { 1447 String compiler, String dir, optionsFromFile) {
1458 assert (['dart2js', 'dart2dart'].contains(compiler)); 1448 assert (['dart2js', 'dart2dart'].contains(compiler));
1459 String executable;
1460 List<String> args; 1449 List<String> args;
1461 if (compilerPath.endsWith('.dart')) { 1450 if (compilerPath.endsWith('.dart')) {
1462 // Run the compiler script via the Dart VM. 1451 // Run the compiler script via the Dart VM.
1463 executable = dartVmBinaryFileName;
1464 args = [compilerPath]; 1452 args = [compilerPath];
1465 } else { 1453 } else {
1466 executable = compilerPath;
1467 args = []; 1454 args = [];
1468 } 1455 }
1469 args.addAll(TestUtils.standardOptions(configuration)); 1456 args.addAll(TestUtils.standardOptions(configuration));
1470 String packageRoot = 1457 String packageRoot =
1471 packageRootArgument(optionsFromFile['packageRoot']); 1458 packageRootArgument(optionsFromFile['packageRoot']);
1472 if (packageRoot != null) args.add(packageRoot); 1459 if (packageRoot != null) args.add(packageRoot);
1473 args.add('--out=$outputFile'); 1460 args.add('--out=$outputFile');
1474 if (configuration['csp']) args.add('--csp'); 1461 if (configuration['csp']) args.add('--csp');
1475 args.add(inputFile); 1462 args.add(inputFile);
1476 List<String> options = optionsFromFile['sharedOptions']; 1463 List<String> options = optionsFromFile['sharedOptions'];
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 ['tests/lib/analyzer/analyze_library.status']); 1892 ['tests/lib/analyzer/analyze_library.status']);
1906 1893
1907 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { 1894 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) {
1908 var options = super.additionalOptions(filePath); 1895 var options = super.additionalOptions(filePath);
1909 // NOTE: This flag has been deprecated. 1896 // NOTE: This flag has been deprecated.
1910 options.add('--show-sdk-warnings'); 1897 options.add('--show-sdk-warnings');
1911 return options; 1898 return options;
1912 } 1899 }
1913 1900
1914 bool isTestFile(String filename) { 1901 bool isTestFile(String filename) {
1915 var sep = Platform.pathSeparator;
1916 // NOTE: We exclude tests and patch files for now. 1902 // NOTE: We exclude tests and patch files for now.
1917 return filename.endsWith(".dart") && 1903 return filename.endsWith(".dart") &&
1918 !filename.endsWith("_test.dart") && 1904 !filename.endsWith("_test.dart") &&
1919 !filename.contains("_internal/compiler/js_lib"); 1905 !filename.contains("_internal/compiler/js_lib");
1920 } 1906 }
1921 1907
1922 bool get listRecursively => true; 1908 bool get listRecursively => true;
1923 } 1909 }
1924 1910
1925 1911
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 1995
2010 localPackageDirectories.forEach(enqueueTestCase); 1996 localPackageDirectories.forEach(enqueueTestCase);
2011 localSampleDirectories.forEach(enqueueTestCase); 1997 localSampleDirectories.forEach(enqueueTestCase);
2012 1998
2013 doTest = null; 1999 doTest = null;
2014 // Notify we're done 2000 // Notify we're done
2015 if (onDone != null) onDone(); 2001 if (onDone != null) onDone();
2016 } 2002 }
2017 2003
2018 doTest = onTest; 2004 doTest = onTest;
2019 Map<String, String> _localPackageDirectories;
2020 Map<String, String> _localSampleDirectories;
2021 List<String> statusFiles = [ 2005 List<String> statusFiles = [
2022 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()]; 2006 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()];
2023 ReadTestExpectations(statusFiles, configuration).then((expectations) { 2007 ReadTestExpectations(statusFiles, configuration).then((expectations) {
2024 Future.wait([discoverPackagesInRepository(), 2008 Future.wait([discoverPackagesInRepository(),
2025 discoverSamplesInRepository()]).then((List results) { 2009 discoverSamplesInRepository()]).then((List results) {
2026 Map packageDirectories = results[0]; 2010 Map packageDirectories = results[0];
2027 Map sampleDirectories = results[1]; 2011 Map sampleDirectories = results[1];
2028 enqueueTestCases(packageDirectories, sampleDirectories, expectations); 2012 enqueueTestCases(packageDirectories, sampleDirectories, expectations);
2029 }); 2013 });
2030 }); 2014 });
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 * $pass tests are expected to pass 2468 * $pass tests are expected to pass
2485 * $failOk tests are expected to fail that we won't fix 2469 * $failOk tests are expected to fail that we won't fix
2486 * $fail tests are expected to fail that we should fix 2470 * $fail tests are expected to fail that we should fix
2487 * $crash tests are expected to crash that we should fix 2471 * $crash tests are expected to crash that we should fix
2488 * $timeout tests are allowed to timeout 2472 * $timeout tests are allowed to timeout
2489 * $compileErrorSkip tests are skipped on browsers due to compile-time error 2473 * $compileErrorSkip tests are skipped on browsers due to compile-time error
2490 """; 2474 """;
2491 print(report); 2475 print(report);
2492 } 2476 }
2493 } 2477 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698