| 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"; | 
 |  11 import "dart:convert"; | 
|  10 import "dart:io"; |  12 import "dart:io"; | 
|  11 import "dart:async"; |  13  | 
|  12 import "package:path/path.dart"; |  14 import "package:path/path.dart"; | 
|  13  |  15  | 
|  14 // Coverage tool script relative to the path of this test. |  16 // Coverage tool script relative to the path of this test. | 
|  15 var coverageToolScript = "../../tools/coverage.dart"; |  17 var coverageToolScript = "../../tools/coverage.dart"; | 
|  16  |  18  | 
|  17 // Coverage target script relative to this test. |  19 // Coverage target script relative to this test. | 
|  18 var coverageTargetScript = "../language/hello_dart_test.dart"; |  20 var coverageTargetScript = "../language/hello_dart_test.dart"; | 
|  19 var targPath; |  21 var targPath; | 
|  20  |  22  | 
|  21 Process coverageToolProcess; |  23 Process coverageToolProcess; | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  57   sourceLines = new File(targPath).readAsLinesSync(); |  59   sourceLines = new File(targPath).readAsLinesSync(); | 
|  58   assert(sourceLines != null); |  60   assert(sourceLines != null); | 
|  59  |  61  | 
|  60   var processOpts = [ "--compile_all", toolPath, targPath ]; |  62   var processOpts = [ "--compile_all", toolPath, targPath ]; | 
|  61  |  63  | 
|  62   Process.start(Platform.executable, processOpts).then((Process process) { |  64   Process.start(Platform.executable, processOpts).then((Process process) { | 
|  63     coverageToolProcess = process; |  65     coverageToolProcess = process; | 
|  64     coverageToolProcess.stdin.close(); |  66     coverageToolProcess.stdin.close(); | 
|  65     var stdoutStringStream = coverageToolProcess.stdout |  67     var stdoutStringStream = coverageToolProcess.stdout | 
|  66         .transform(new StringDecoder()) |  68         .transform(new StringDecoder()) | 
|  67         .transform(new LineTransformer()); |  69         .transform(new LineSplitter()); | 
|  68  |  70  | 
|  69     var stderrStringStream = coverageToolProcess.stderr |  71     var stderrStringStream = coverageToolProcess.stderr | 
|  70         .transform(new StringDecoder()) |  72         .transform(new StringDecoder()) | 
|  71         .transform(new LineTransformer()); |  73         .transform(new LineSplitter()); | 
|  72  |  74  | 
|  73     // 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 | 
|  74     // tool process closed, and coverage tool process terminated. |  76     // tool process closed, and coverage tool process terminated. | 
|  75     var futures = []; |  77     var futures = []; | 
|  76     var subscription = stdoutStringStream.listen(onCoverageOutput); |  78     var subscription = stdoutStringStream.listen(onCoverageOutput); | 
|  77     futures.add(subscription.asFuture(true)); |  79     futures.add(subscription.asFuture(true)); | 
|  78     subscription = stderrStringStream.listen(onCoverageOutput); |  80     subscription = stderrStringStream.listen(onCoverageOutput); | 
|  79     futures.add(subscription.asFuture(true)); |  81     futures.add(subscription.asFuture(true)); | 
|  80     futures.add(coverageToolProcess.exitCode.then(checkExitCode)); |  82     futures.add(coverageToolProcess.exitCode.then(checkExitCode)); | 
|  81     Future.wait(futures).then((results) { |  83     Future.wait(futures).then((results) { | 
|  82       checkSuccess(); |  84       checkSuccess(); | 
|  83       if (results.contains(false)) exit(-1); |  85       if (results.contains(false)) exit(-1); | 
|  84     }); |  86     }); | 
|  85   }); |  87   }); | 
|  86 } |  88 } | 
| OLD | NEW |