anchor.diff:      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();
  +      if (results.contains(false)) exit(-1);
  +    });
     });
   }
  
positive.code: // runs.
  
  import "dart:io";
  import "dart:utf";
  
  // Coverage tool script relative to the path of this test.
  var coverageToolScript = "../../tools/coverage.dart";
  
negative.code: void onCoverageOutput(String line) {
    print("COV: $line");
    if (nextLineToMatch < sourceLines.length) {
      if (line.endsWith("|" + sourceLines[nextLineToMatch])) {
        nextLineToMatch++;
      }
    }
  }
  
  bool checkExitCode(exitCode) {
    var pid = coverageToolProcess.pid;
    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);
    }
  }
  
  