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 /// A library for code coverage support for Dart. | 5 /// A library for code coverage support for Dart. |
6 library runtime.coverage.impl; | 6 library runtime.coverage.impl; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection' show SplayTreeMap; | 9 import 'dart:collection' show SplayTreeMap; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 import 'models.dart'; | 21 import 'models.dart'; |
22 | 22 |
23 /// Run the [targetPath] with code coverage rewriting. | 23 /// Run the [targetPath] with code coverage rewriting. |
24 /// Redirects stdandard process streams. | 24 /// Redirects stdandard process streams. |
25 /// On process exit dumps coverage statistics into the [outPath]. | 25 /// On process exit dumps coverage statistics into the [outPath]. |
26 void runServerApplication(String targetPath, String outPath) { | 26 void runServerApplication(String targetPath, String outPath) { |
27 var targetFolder = pathos.dirname(targetPath); | 27 var targetFolder = pathos.dirname(targetPath); |
28 var targetName = pathos.basename(targetPath); | 28 var targetName = pathos.basename(targetPath); |
29 var server = new CoverageServer(targetFolder, targetPath, outPath); | 29 var server = new CoverageServer(targetFolder, targetPath, outPath); |
30 server.start().then((port) { | 30 server.start().then((port) { |
31 var options = new Options(); | |
32 var targetArgs = ['http://127.0.0.1:$port/$targetName']; | 31 var targetArgs = ['http://127.0.0.1:$port/$targetName']; |
33 var dartExecutable = options.executable; | 32 var dartExecutable = Platform.executable; |
34 return Process.start(dartExecutable, targetArgs); | 33 return Process.start(dartExecutable, targetArgs); |
35 }).then((process) { | 34 }).then((process) { |
36 stdin.pipe(process.stdin); | 35 stdin.pipe(process.stdin); |
37 process.stdout.pipe(stdout); | 36 process.stdout.pipe(stdout); |
38 process.stderr.pipe(stderr); | 37 process.stderr.pipe(stderr); |
39 return process.exitCode; | 38 return process.exitCode; |
40 }).then(exit).catchError((e) { | 39 }).then(exit).catchError((e) { |
41 log.severe('Error starting $targetPath. $e'); | 40 log.severe('Error starting $targetPath. $e'); |
42 }); | 41 }); |
43 } | 42 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 var lastOffset = 0; | 331 var lastOffset = 0; |
333 offsetFragmentMap.forEach((offset, fragment) { | 332 offsetFragmentMap.forEach((offset, fragment) { |
334 sb.write(_code.substring(lastOffset, offset)); | 333 sb.write(_code.substring(lastOffset, offset)); |
335 sb.write(fragment); | 334 sb.write(fragment); |
336 lastOffset = offset; | 335 lastOffset = offset; |
337 }); | 336 }); |
338 sb.write(_code.substring(lastOffset, _code.length)); | 337 sb.write(_code.substring(lastOffset, _code.length)); |
339 return sb.toString(); | 338 return sb.toString(); |
340 } | 339 } |
341 } | 340 } |
OLD | NEW |