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

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

Issue 18065003: Update checked in binary to version 0.5.19.0 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | « 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,
11 * and creating [TestCase]s for those files that meet the relevant criteria. 11 * and creating [TestCase]s for those files that meet the relevant criteria.
12 * - Preparing tests, including copying files and frameworks to temporary 12 * - Preparing tests, including copying files and frameworks to temporary
13 * directories, and computing the command line and arguments to be run. 13 * directories, and computing the command line and arguments to be run.
14 */ 14 */
15 library test_suite; 15 library test_suite;
16 16
17 import "dart:async"; 17 import "dart:async";
18 import "dart:io"; 18 import "dart:io";
19 import "dart:isolate"; 19 import "dart:isolate";
20 import "dart:uri";
21 import "drt_updater.dart"; 20 import "drt_updater.dart";
22 import "multitest.dart"; 21 import "multitest.dart";
23 import "status_file_parser.dart"; 22 import "status_file_parser.dart";
24 import "test_runner.dart"; 23 import "test_runner.dart";
25 import "utils.dart"; 24 import "utils.dart";
26 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; 25 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR;
27 26
28 part "browser_test.dart"; 27 part "browser_test.dart";
29 28
30 29
(...skipping 11 matching lines...) Expand all
42 Set<String> multitestOutcome}); 41 Set<String> multitestOutcome});
43 42
44 typedef void VoidFunction(); 43 typedef void VoidFunction();
45 44
46 /** 45 /**
47 * Calls [function] asynchronously. Returns a future that completes with the 46 * Calls [function] asynchronously. Returns a future that completes with the
48 * result of the function. If the function is `null`, returns a future that 47 * result of the function. If the function is `null`, returns a future that
49 * completes immediately with `null`. 48 * completes immediately with `null`.
50 */ 49 */
51 Future asynchronously(function()) { 50 Future asynchronously(function()) {
52 if (function == null) return new Future.immediate(null); 51 if (function == null) return new Future.value(null);
53 52
54 var completer = new Completer(); 53 var completer = new Completer();
55 Timer.run(() => completer.complete(function())); 54 Timer.run(() => completer.complete(function()));
56 55
57 return completer.future; 56 return completer.future;
58 } 57 }
59 58
60 /** A completer that waits until all added [Future]s complete. */ 59 /** A completer that waits until all added [Future]s complete. */
61 // TODO(rnystrom): Copied from web_components. Remove from here when it gets 60 // TODO(rnystrom): Copied from web_components. Remove from here when it gets
62 // added to dart:core. (See #6626.) 61 // added to dart:core. (See #6626.)
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), 482 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'),
484 recursive: true); 483 recursive: true);
485 } 484 }
486 485
487 List<Uri> get dart2JsBootstrapDependencies { 486 List<Uri> get dart2JsBootstrapDependencies {
488 if (!useSdk) return []; 487 if (!useSdk) return [];
489 488
490 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( 489 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join(
491 new Path('dart-sdk/bin/snapshots/' 490 new Path('dart-sdk/bin/snapshots/'
492 'utils_wrapper.dart.snapshot'))).toString(); 491 'utils_wrapper.dart.snapshot'))).toString();
493 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)]; 492 return [new Uri(scheme: 'file', path: snapshotPath)];
494 } 493 }
495 494
496 /** 495 /**
497 * The default implementation assumes a file is a test if 496 * The default implementation assumes a file is a test if
498 * it ends in "Test.dart". 497 * it ends in "Test.dart".
499 */ 498 */
500 bool isTestFile(String filename) { 499 bool isTestFile(String filename) {
501 // Use the specified predicate, if provided. 500 // Use the specified predicate, if provided.
502 if (isTestFilePredicate != null) return isTestFilePredicate(filename); 501 if (isTestFilePredicate != null) return isTestFilePredicate(filename);
503 502
(...skipping 29 matching lines...) Expand all
533 } 532 }
534 533
535 /** 534 /**
536 * If Content shell/Dartium is required, and not yet updated, waits for 535 * If Content shell/Dartium is required, and not yet updated, waits for
537 * the update then completes. Otherwise completes immediately. 536 * the update then completes. Otherwise completes immediately.
538 */ 537 */
539 Future updateDartium() { 538 Future updateDartium() {
540 var completer = new Completer(); 539 var completer = new Completer();
541 var updater = runtimeUpdater(configuration); 540 var updater = runtimeUpdater(configuration);
542 if (updater == null || updater.updated) { 541 if (updater == null || updater.updated) {
543 return new Future.immediate(null); 542 return new Future.value(null);
544 } 543 }
545 544
546 assert(updater.isActive); 545 assert(updater.isActive);
547 updater.onUpdated.add(() => completer.complete(null)); 546 updater.onUpdated.add(() => completer.complete(null));
548 547
549 return completer.future; 548 return completer.future;
550 } 549 }
551 550
552 /** 551 /**
553 * Reads the status files and completes with the parsed expectations. 552 * Reads the status files and completes with the parsed expectations.
(...skipping 29 matching lines...) Expand all
583 } 582 }
584 583
585 return completer.future; 584 return completer.future;
586 } 585 }
587 586
588 Future enqueueTests() { 587 Future enqueueTests() {
589 Directory dir = new Directory.fromPath(suiteDir); 588 Directory dir = new Directory.fromPath(suiteDir);
590 return dir.exists().then((exists) { 589 return dir.exists().then((exists) {
591 if (!exists) { 590 if (!exists) {
592 print('Directory containing tests missing: ${suiteDir.toNativePath()}'); 591 print('Directory containing tests missing: ${suiteDir.toNativePath()}');
593 return new Future.immediate(null); 592 return new Future.value(null);
594 } else { 593 } else {
595 var group = new FutureGroup(); 594 var group = new FutureGroup();
596 enqueueDirectory(dir, group); 595 enqueueDirectory(dir, group);
597 return group.future; 596 return group.future;
598 } 597 }
599 }); 598 });
600 } 599 }
601 600
602 void enqueueDirectory(Directory dir, FutureGroup group) { 601 void enqueueDirectory(Directory dir, FutureGroup group) {
603 var listCompleter = new Completer(); 602 var listCompleter = new Completer();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 var url= 'http://$local_ip:$serverPort$pathComponent' 875 var url= 'http://$local_ip:$serverPort$pathComponent'
877 '?crossOriginPort=$crossOriginPort'; 876 '?crossOriginPort=$crossOriginPort';
878 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { 877 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) {
879 url= '${url}&group=${subtestNames[subtestIndex]}'; 878 url= '${url}&group=${subtestNames[subtestIndex]}';
880 } 879 }
881 return url; 880 return url;
882 } 881 }
883 882
884 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) { 883 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) {
885 File file = new File(dartWrapperFilename); 884 File file = new File(dartWrapperFilename);
886 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE); 885 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE);
887 886
888 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); 887 var usePackageImport = dartLibraryFilename.segments().contains("pkg");
889 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); 888 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename);
890 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, 889 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport,
891 libraryPathComponent)); 890 libraryPathComponent));
892 dartWrapper.closeSync(); 891 dartWrapper.closeSync();
893 } 892 }
894 893
895 894
896 /** 895 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 // test.dart will import the dart test. 938 // test.dart will import the dart test.
940 _createWrapperFile(dartWrapperFilename, filePath); 939 _createWrapperFile(dartWrapperFilename, filePath);
941 } else { 940 } else {
942 dartWrapperFilename = filename; 941 dartWrapperFilename = filename;
943 } 942 }
944 String scriptPath = (compiler == 'none') ? 943 String scriptPath = (compiler == 'none') ?
945 dartWrapperFilename : compiledDartWrapperFilename; 944 dartWrapperFilename : compiledDartWrapperFilename;
946 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); 945 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
947 946
948 // Create the HTML file for the test. 947 // Create the HTML file for the test.
949 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); 948 RandomAccessFile htmlTest =
949 new File(htmlPath).openSync(mode: FileMode.WRITE);
950 String content = null; 950 String content = null;
951 Path dir = filePath.directoryPath; 951 Path dir = filePath.directoryPath;
952 String nameNoExt = filePath.filenameWithoutExtension; 952 String nameNoExt = filePath.filenameWithoutExtension;
953 Path pngPath = dir.append('$nameNoExt.png'); 953 Path pngPath = dir.append('$nameNoExt.png');
954 Path txtPath = dir.append('$nameNoExt.txt'); 954 Path txtPath = dir.append('$nameNoExt.txt');
955 Path expectedOutput = null; 955 Path expectedOutput = null;
956 if (new File.fromPath(pngPath).existsSync()) { 956 if (new File.fromPath(pngPath).existsSync()) {
957 expectedOutput = pngPath; 957 expectedOutput = pngPath;
958 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath")); 958 content = getHtmlLayoutContents(scriptType, new Path("$scriptPath"));
959 } else if (new File.fromPath(txtPath).existsSync()) { 959 } else if (new File.fromPath(txtPath).existsSync()) {
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 class TestUtils { 1722 class TestUtils {
1723 /** 1723 /**
1724 * The libraries in this directory relies on finding various files 1724 * The libraries in this directory relies on finding various files
1725 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If 1725 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If
1726 * the main script using 'test_suite.dart' is not there, the main 1726 * the main script using 'test_suite.dart' is not there, the main
1727 * script must set this to '.../dart/tools/test.dart'. 1727 * script must set this to '.../dart/tools/test.dart'.
1728 */ 1728 */
1729 static String testScriptPath = new Options().script; 1729 static String testScriptPath = new Options().script;
1730 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); 1730 static LastModifiedCache lastModifiedCache = new LastModifiedCache();
1731 static Path currentWorkingDirectory = 1731 static Path currentWorkingDirectory =
1732 new Path(new Directory.current().path); 1732 new Path(Directory.current.path);
1733 /** 1733 /**
1734 * Creates a directory using a [relativePath] to an existing 1734 * Creates a directory using a [relativePath] to an existing
1735 * [base] directory if that [relativePath] does not already exist. 1735 * [base] directory if that [relativePath] does not already exist.
1736 */ 1736 */
1737 static Directory mkdirRecursive(Path base, Path relativePath) { 1737 static Directory mkdirRecursive(Path base, Path relativePath) {
1738 if (relativePath.isAbsolute) { 1738 if (relativePath.isAbsolute) {
1739 base = new Path('/'); 1739 base = new Path('/');
1740 } 1740 }
1741 Directory dir = new Directory.fromPath(base); 1741 Directory dir = new Directory.fromPath(base);
1742 assert(dir.existsSync()); 1742 assert(dir.existsSync());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 * $pass tests are expected to pass 1965 * $pass tests are expected to pass
1966 * $failOk tests are expected to fail that we won't fix 1966 * $failOk tests are expected to fail that we won't fix
1967 * $fail tests are expected to fail that we should fix 1967 * $fail tests are expected to fail that we should fix
1968 * $crash tests are expected to crash that we should fix 1968 * $crash tests are expected to crash that we should fix
1969 * $timeout tests are allowed to timeout 1969 * $timeout tests are allowed to timeout
1970 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1970 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1971 """; 1971 """;
1972 print(report); 1972 print(report);
1973 } 1973 }
1974 } 1974 }
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