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

Unified Diff: tests/standalone/coverage_test.dart

Issue 16305013: Fix coverage test (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/coverage_test.dart
===================================================================
--- tests/standalone/coverage_test.dart (revision 23550)
+++ tests/standalone/coverage_test.dart (working copy)
@@ -8,7 +8,7 @@
// runs.
import "dart:io";
-import "dart:utf";
+import "dart:async";
// Coverage tool script relative to the path of this test.
var coverageToolScript = "../../tools/coverage.dart";
@@ -24,20 +24,25 @@
void onCoverageOutput(String line) {
print("COV: $line");
if (nextLineToMatch < sourceLines.length) {
- if (line.endsWith(sourceLines[nextLineToMatch])) {
+ if (line.endsWith("|" + sourceLines[nextLineToMatch])) {
nextLineToMatch++;
}
}
}
-void onCoverageExit(exitCode) {
+bool checkExitCode(exitCode) {
var pid = coverageToolProcess.pid;
- print("process $pid terminated with exit code $exitCode.");
- if (nextLineToMatch < sourceLines.length) {
+ print("Coverage tool process (pid $pid) terminated with "
+ "exit code $exitCode.");
+ return exitCode == 0;
+}
+
+void checkSuccess() {
+ if (nextLineToMatch == sourceLines.length) {
+ print("Successfully matched all lines of '$targPath'");
+ } else {
print("Error: could not match all source code lines of '$targPath'");
exit(-1);
- } else {
- print("Successfully matched all lines of '$targPath'");
}
}
@@ -63,13 +68,21 @@
var stdoutStringStream = coverageToolProcess.stdout
.transform(new StringDecoder())
.transform(new LineTransformer());
- stdoutStringStream.listen(onCoverageOutput);
var stderrStringStream = coverageToolProcess.stderr
.transform(new StringDecoder())
.transform(new LineTransformer());
- stderrStringStream.listen(onCoverageOutput);
- coverageToolProcess.exitCode.then(onCoverageExit);
+ // Wait for 3 future events: stdout and stderr streams of the coverage
+ // tool process closed, and coverage tool process terminated.
+ var futures = [];
+ var subscription = stdoutStringStream.listen(onCoverageOutput);
+ futures.add(subscription.asFuture(true));
+ subscription = stderrStringStream.listen(onCoverageOutput);
+ futures.add(subscription.asFuture(true));
+ futures.add(coverageToolProcess.exitCode.then(checkExitCode));
+ Future.wait(futures).then((results) {
+ checkSuccess();
ricow1 2013/06/04 05:49:00 you don't really use the return values for anythin
hausner 2013/06/04 16:03:41 Done.
+ });
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698