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

Unified Diff: tools/testing/dart/test_suite.dart

Issue 12864003: Revert "Update the test runner to use the new dart:io API" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | tools/testing/dart/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_suite.dart
diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
index 56dcdcebf58df37d4079260fc1e901ab826c2309..2a33c2fee5a6acc6e62873f7eb3302251edcd2f2 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -52,7 +52,9 @@ Future asynchronously(function()) {
if (function == null) return new Future.immediate(null);
var completer = new Completer();
- Timer.run(() => completer.complete(function()));
+ new Timer(0, (_) {
+ completer.complete(function());
+ });
return completer.future;
}
@@ -79,7 +81,7 @@ class FutureGroup {
_pending++;
var handledTaskFuture = task.catchError((e) {
if (!wasCompleted) {
- _completer.completeError(e.error, e.stackTrace);
+ _completer.completeError(e.error, task.stackTrace);
wasCompleted = true;
}
}).then((_) {
@@ -142,7 +144,6 @@ abstract class TestSuite {
case 'dartc':
case 'new_analyzer':
name = executablePath;
- break;
case 'dart2js':
case 'dart2dart':
var prefix = 'sdk/bin/';
@@ -256,12 +257,10 @@ abstract class TestSuite {
void ccTestLister() {
port.receive((String runnerPath, SendPort replyTo) {
Future processFuture = Process.start(runnerPath, ["--list"]);
- processFuture.then((Process p) {
+ processFuture.then((p) {
// Drain stderr to not leak resources.
- p.stderr.listen((_) { });
- Stream<String> stdoutStream =
- p.stdout.transform(new StringDecoder())
- .transform(new LineTransformer());
+ p.stderr.onData = p.stderr.read;
+ StringInputStream stdoutStream = new StringInputStream(p.stdout);
var streamDone = false;
var processExited = false;
checkDone() {
@@ -269,15 +268,15 @@ void ccTestLister() {
replyTo.send("");
}
}
- stdoutStream.listen((String line) {
+ stdoutStream.onLine = () {
+ String line = stdoutStream.readLine();
replyTo.send(line);
- },
- onDone: () {
+ };
+ stdoutStream.onClosed = () {
streamDone = true;
checkDone();
- });
-
- p.exitCode.then((code) {
+ };
+ p.onExit = (code) {
if (code < 0) {
print("Failed to list tests: $runnerPath --list");
replyTo.send("");
@@ -285,7 +284,7 @@ void ccTestLister() {
processExited = true;
checkDone();
}
- });
+ };
port.close();
}).catchError((e) {
print("Failed to list tests: $runnerPath --list");
@@ -587,11 +586,9 @@ class StandardTestSuite extends TestSuite {
var listCompleter = new Completer();
group.add(listCompleter.future);
- var lister = dir.list(recursive: listRecursively)
- .listen((FileSystemEntity fse) {
- if (fse is File) enqueueFile(fse.path, group);
- },
- onDone: listCompleter.complete);
+ var lister = dir.list(recursive: listRecursively);
+ lister.onFile = (file) => enqueueFile(file, group);
+ lister.onDone = listCompleter.complete;
}
void enqueueFile(String filename, FutureGroup group) {
@@ -837,10 +834,10 @@ class StandardTestSuite extends TestSuite {
return "/$PREFIX_DARTDIR/$fileRelativeToDartDir";
}
// Unreachable
- Expect.fail('This should be unreachable.');
+ Except.fail('This should be unreachable.');
}
- String _getUriForBrowserTest(TestInformation info,
+ void _getUriForBrowserTest(TestInformation info,
String pathComponent,
subtestNames,
subtestIndex) {
@@ -1504,8 +1501,8 @@ class StandardTestSuite extends TestSuite {
// Using stderr.writeString to avoid breaking dartc/junit_tests
// which parses the output of the --list option.
- stderr.writeln(
- "Warning: deprecated @dynamic-type-error tag used in $filePath");
+ stderr.writeString(
+ "Warning: deprecated @dynamic-type-error tag used in $filePath\n");
}
return {
@@ -1629,10 +1626,9 @@ class JUnitTestSuite extends TestSuite {
directoryPath = '$dartDir/$directoryPath';
Directory dir = new Directory(directoryPath);
- dir.list(recursive: true).listen((FileSystemEntity fse) {
- if (fse is File) processFile(fse.path);
- },
- onDone: createTest);
+ var lister = dir.list(recursive: true);
+ lister.onFile = processFile;
+ lister.onDone = createTest;
}
void processFile(String filename) {
@@ -1648,7 +1644,7 @@ class JUnitTestSuite extends TestSuite {
}
}
- void createTest() {
+ void createTest(successIgnored) {
var sdkDir = "$buildDir/dart-sdk".trim();
List<String> args = <String>[
'-ea',
@@ -1694,7 +1690,7 @@ class JUnitTestSuite extends TestSuite {
}
class LastModifiedCache {
- Map<String, DateTime> _cache = <String, DateTime>{};
+ Map<String, Date> _cache = <String, Date>{};
/**
* Returns the last modified date of the given [uri].
@@ -1705,7 +1701,7 @@ class LastModifiedCache {
* In case [uri] is not a local file, this method will always return
* the current date.
*/
- DateTime getLastModified(Uri uri) {
+ Date getLastModified(Uri uri) {
if (uri.scheme == "file") {
if (_cache.containsKey(uri.path)) {
return _cache[uri.path];
@@ -1763,8 +1759,11 @@ class TestUtils {
* Assumes that the directory for [dest] already exists.
*/
static Future copyFile(Path source, Path dest) {
- return new File.fromPath(source).openRead()
- .pipe(new File.fromPath(dest).openWrite());
+ var output = new File.fromPath(dest).openOutputStream();
+ new File.fromPath(source).openInputStream().pipe(output);
+ var completer = new Completer();
+ output.onClosed = (){ completer.complete(null); };
+ return completer.future;
}
static Path debugLogfile() {
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | tools/testing/dart/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698