| 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 a dart script as | 5 // This test forks a second vm process that runs a dart script as |
| 6 // a debug target, single stepping through the entire program, and | 6 // a debug target, single stepping through the entire program, and |
| 7 // recording each breakpoint. At the end, a coverage map of the source | 7 // recording each breakpoint. At the end, a coverage map of the source |
| 8 // is printed. | 8 // is printed. |
| 9 // | 9 // |
| 10 // Usage: dart coverage.dart [--wire] [--verbose] target_script.dart | 10 // Usage: dart coverage.dart [--wire] [--verbose] target_script.dart |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 print(url); | 94 print(url); |
| 95 tokenCounts.forEach((tp, bpCount) { | 95 tokenCounts.forEach((tp, bpCount) { |
| 96 int lineNumber = tokenPosToLine[tp]; | 96 int lineNumber = tokenPosToLine[tp]; |
| 97 var lineCount = lineCounts[lineNumber]; | 97 var lineCount = lineCounts[lineNumber]; |
| 98 // Remember maximum breakpoint count of all tokens in this line. | 98 // Remember maximum breakpoint count of all tokens in this line. |
| 99 if (lineCount == null || lineCount < bpCount) { | 99 if (lineCount == null || lineCount < bpCount) { |
| 100 lineCounts[lineNumber] = bpCount; | 100 lineCounts[lineNumber] = bpCount; |
| 101 } | 101 } |
| 102 }); | 102 }); |
| 103 | 103 |
| 104 List lines = new File(Uri.parse(url).path).readAsLinesSync(); | 104 String srcPath = new Path(Uri.parse(url).path).toNativePath(); |
| 105 List lines = new File(srcPath).readAsLinesSync(); |
| 105 for (int line = 1; line <= lines.length; line++) { | 106 for (int line = 1; line <= lines.length; line++) { |
| 106 String prefix = " "; | 107 String prefix = " "; |
| 107 if (lineCounts.containsKey(line)) { | 108 if (lineCounts.containsKey(line)) { |
| 108 prefix = lineCounts[line].toString(); | 109 prefix = lineCounts[line].toString(); |
| 109 StringBuffer b = new StringBuffer(); | 110 StringBuffer b = new StringBuffer(); |
| 110 for (int i = prefix.length; i < 6; i++) b.write(" "); | 111 for (int i = prefix.length; i < 6; i++) b.write(" "); |
| 111 b.write(prefix); | 112 b.write(prefix); |
| 112 prefix = b.toString(); | 113 prefix = b.toString(); |
| 113 } | 114 } |
| 114 print("${prefix}|${lines[line-1]}"); | 115 print("${prefix}|${lines[line-1]}"); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 targetOpts.add(str); | 485 targetOpts.add(str); |
| 485 break; | 486 break; |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 | 489 |
| 489 Process.start(options.executable, targetOpts).then((Process process) { | 490 Process.start(options.executable, targetOpts).then((Process process) { |
| 490 process.stdin.close(); | 491 process.stdin.close(); |
| 491 var debugger = new Debugger(process); | 492 var debugger = new Debugger(process); |
| 492 }); | 493 }); |
| 493 } | 494 } |
| OLD | NEW |