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

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

Issue 17274002: Revert 24086 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, 6 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";
20 import "drt_updater.dart"; 21 import "drt_updater.dart";
21 import "multitest.dart"; 22 import "multitest.dart";
22 import "status_file_parser.dart"; 23 import "status_file_parser.dart";
23 import "test_runner.dart"; 24 import "test_runner.dart";
24 import "utils.dart"; 25 import "utils.dart";
25 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; 26 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR;
26 27
27 part "browser_test.dart"; 28 part "browser_test.dart";
28 29
29 30
(...skipping 11 matching lines...) Expand all
41 Set<String> multitestOutcome}); 42 Set<String> multitestOutcome});
42 43
43 typedef void VoidFunction(); 44 typedef void VoidFunction();
44 45
45 /** 46 /**
46 * Calls [function] asynchronously. Returns a future that completes with the 47 * Calls [function] asynchronously. Returns a future that completes with the
47 * result of the function. If the function is `null`, returns a future that 48 * result of the function. If the function is `null`, returns a future that
48 * completes immediately with `null`. 49 * completes immediately with `null`.
49 */ 50 */
50 Future asynchronously(function()) { 51 Future asynchronously(function()) {
51 if (function == null) return new Future.value(null); 52 if (function == null) return new Future.immediate(null);
52 53
53 var completer = new Completer(); 54 var completer = new Completer();
54 Timer.run(() => completer.complete(function())); 55 Timer.run(() => completer.complete(function()));
55 56
56 return completer.future; 57 return completer.future;
57 } 58 }
58 59
59 /** A completer that waits until all added [Future]s complete. */ 60 /** A completer that waits until all added [Future]s complete. */
60 // TODO(rnystrom): Copied from web_components. Remove from here when it gets 61 // TODO(rnystrom): Copied from web_components. Remove from here when it gets
61 // added to dart:core. (See #6626.) 62 // added to dart:core. (See #6626.)
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), 483 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'),
483 recursive: true); 484 recursive: true);
484 } 485 }
485 486
486 List<Uri> get dart2JsBootstrapDependencies { 487 List<Uri> get dart2JsBootstrapDependencies {
487 if (!useSdk) return []; 488 if (!useSdk) return [];
488 489
489 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( 490 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join(
490 new Path('dart-sdk/bin/snapshots/' 491 new Path('dart-sdk/bin/snapshots/'
491 'utils_wrapper.dart.snapshot'))).toString(); 492 'utils_wrapper.dart.snapshot'))).toString();
492 return [new Uri(scheme: 'file', path: snapshotPath)]; 493 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)];
493 } 494 }
494 495
495 /** 496 /**
496 * The default implementation assumes a file is a test if 497 * The default implementation assumes a file is a test if
497 * it ends in "Test.dart". 498 * it ends in "Test.dart".
498 */ 499 */
499 bool isTestFile(String filename) { 500 bool isTestFile(String filename) {
500 // Use the specified predicate, if provided. 501 // Use the specified predicate, if provided.
501 if (isTestFilePredicate != null) return isTestFilePredicate(filename); 502 if (isTestFilePredicate != null) return isTestFilePredicate(filename);
502 503
(...skipping 29 matching lines...) Expand all
532 } 533 }
533 534
534 /** 535 /**
535 * If Content shell/Dartium is required, and not yet updated, waits for 536 * If Content shell/Dartium is required, and not yet updated, waits for
536 * the update then completes. Otherwise completes immediately. 537 * the update then completes. Otherwise completes immediately.
537 */ 538 */
538 Future updateDartium() { 539 Future updateDartium() {
539 var completer = new Completer(); 540 var completer = new Completer();
540 var updater = runtimeUpdater(configuration); 541 var updater = runtimeUpdater(configuration);
541 if (updater == null || updater.updated) { 542 if (updater == null || updater.updated) {
542 return new Future.value(null); 543 return new Future.immediate(null);
543 } 544 }
544 545
545 assert(updater.isActive); 546 assert(updater.isActive);
546 updater.onUpdated.add(() => completer.complete(null)); 547 updater.onUpdated.add(() => completer.complete(null));
547 548
548 return completer.future; 549 return completer.future;
549 } 550 }
550 551
551 /** 552 /**
552 * Reads the status files and completes with the parsed expectations. 553 * Reads the status files and completes with the parsed expectations.
(...skipping 29 matching lines...) Expand all
582 } 583 }
583 584
584 return completer.future; 585 return completer.future;
585 } 586 }
586 587
587 Future enqueueTests() { 588 Future enqueueTests() {
588 Directory dir = new Directory.fromPath(suiteDir); 589 Directory dir = new Directory.fromPath(suiteDir);
589 return dir.exists().then((exists) { 590 return dir.exists().then((exists) {
590 if (!exists) { 591 if (!exists) {
591 print('Directory containing tests missing: ${suiteDir.toNativePath()}'); 592 print('Directory containing tests missing: ${suiteDir.toNativePath()}');
592 return new Future.value(null); 593 return new Future.immediate(null);
593 } else { 594 } else {
594 var group = new FutureGroup(); 595 var group = new FutureGroup();
595 enqueueDirectory(dir, group); 596 enqueueDirectory(dir, group);
596 return group.future; 597 return group.future;
597 } 598 }
598 }); 599 });
599 } 600 }
600 601
601 void enqueueDirectory(Directory dir, FutureGroup group) { 602 void enqueueDirectory(Directory dir, FutureGroup group) {
602 var listCompleter = new Completer(); 603 var listCompleter = new Completer();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 var url= 'http://$local_ip:$serverPort$pathComponent' 876 var url= 'http://$local_ip:$serverPort$pathComponent'
876 '?crossOriginPort=$crossOriginPort'; 877 '?crossOriginPort=$crossOriginPort';
877 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) { 878 if (info.optionsFromFile['isMultiHtmlTest'] && subtestNames.length > 0) {
878 url= '${url}&group=${subtestNames[subtestIndex]}'; 879 url= '${url}&group=${subtestNames[subtestIndex]}';
879 } 880 }
880 return url; 881 return url;
881 } 882 }
882 883
883 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) { 884 void _createWrapperFile(String dartWrapperFilename, dartLibraryFilename) {
884 File file = new File(dartWrapperFilename); 885 File file = new File(dartWrapperFilename);
885 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); 886 RandomAccessFile dartWrapper = file.openSync(FileMode.WRITE);
886 887
887 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); 888 var usePackageImport = dartLibraryFilename.segments().contains("pkg");
888 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); 889 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename);
889 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, 890 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport,
890 libraryPathComponent)); 891 libraryPathComponent));
891 dartWrapper.closeSync(); 892 dartWrapper.closeSync();
892 } 893 }
893 894
894 895
895 /** 896 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 // test.dart will import the dart test. 939 // test.dart will import the dart test.
939 _createWrapperFile(dartWrapperFilename, filePath); 940 _createWrapperFile(dartWrapperFilename, filePath);
940 } else { 941 } else {
941 dartWrapperFilename = filename; 942 dartWrapperFilename = filename;
942 } 943 }
943 String scriptPath = (compiler == 'none') ? 944 String scriptPath = (compiler == 'none') ?
944 dartWrapperFilename : compiledDartWrapperFilename; 945 dartWrapperFilename : compiledDartWrapperFilename;
945 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); 946 scriptPath = _createUrlPathFromFile(new Path(scriptPath));
946 947
947 // Create the HTML file for the test. 948 // Create the HTML file for the test.
948 RandomAccessFile htmlTest = 949 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE);
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(Directory.current.path); 1732 new Path(new 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