| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // This test forks a second vm process that runs the script tools/coverage.dart | 5 // This test forks a second vm process that runs the script tools/coverage.dart |
| 6 // and verifies that the coverage tool produces its expected output. | 6 // and verifies that the coverage tool produces its expected output. |
| 7 // This test is mainly here to ensure that the coverage tool compiles and | 7 // This test is mainly here to ensure that the coverage tool compiles and |
| 8 // runs. | 8 // runs. |
| 9 | 9 |
| 10 import "dart:async"; | 10 import "dart:async"; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 sourceLines = new File(targPath).readAsLinesSync(); | 59 sourceLines = new File(targPath).readAsLinesSync(); |
| 60 assert(sourceLines != null); | 60 assert(sourceLines != null); |
| 61 | 61 |
| 62 var processOpts = [ "--compile_all", toolPath, targPath ]; | 62 var processOpts = [ "--compile_all", toolPath, targPath ]; |
| 63 | 63 |
| 64 Process.start(Platform.executable, processOpts).then((Process process) { | 64 Process.start(Platform.executable, processOpts).then((Process process) { |
| 65 coverageToolProcess = process; | 65 coverageToolProcess = process; |
| 66 coverageToolProcess.stdin.close(); | 66 coverageToolProcess.stdin.close(); |
| 67 var stdoutStringStream = coverageToolProcess.stdout | 67 var stdoutStringStream = coverageToolProcess.stdout |
| 68 .transform(new StringDecoder()) | 68 .transform(UTF8.decoder) |
| 69 .transform(new LineSplitter()); | 69 .transform(new LineSplitter()); |
| 70 | 70 |
| 71 var stderrStringStream = coverageToolProcess.stderr | 71 var stderrStringStream = coverageToolProcess.stderr |
| 72 .transform(new StringDecoder()) | 72 .transform(UTF8.decoder) |
| 73 .transform(new LineSplitter()); | 73 .transform(new LineSplitter()); |
| 74 | 74 |
| 75 // Wait for 3 future events: stdout and stderr streams of the coverage | 75 // Wait for 3 future events: stdout and stderr streams of the coverage |
| 76 // tool process closed, and coverage tool process terminated. | 76 // tool process closed, and coverage tool process terminated. |
| 77 var futures = []; | 77 var futures = []; |
| 78 var subscription = stdoutStringStream.listen(onCoverageOutput); | 78 var subscription = stdoutStringStream.listen(onCoverageOutput); |
| 79 futures.add(subscription.asFuture(true)); | 79 futures.add(subscription.asFuture(true)); |
| 80 subscription = stderrStringStream.listen(onCoverageOutput); | 80 subscription = stderrStringStream.listen(onCoverageOutput); |
| 81 futures.add(subscription.asFuture(true)); | 81 futures.add(subscription.asFuture(true)); |
| 82 futures.add(coverageToolProcess.exitCode.then(checkExitCode)); | 82 futures.add(coverageToolProcess.exitCode.then(checkExitCode)); |
| 83 Future.wait(futures).then((results) { | 83 Future.wait(futures).then((results) { |
| 84 checkSuccess(); | 84 checkSuccess(); |
| 85 if (results.contains(false)) exit(-1); | 85 if (results.contains(false)) exit(-1); |
| 86 }); | 86 }); |
| 87 }); | 87 }); |
| 88 } | 88 } |
| OLD | NEW |