Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1252)

Side by Side Diff: tests/standalone/coverage_test.dart

Issue 15894015: Add coverage tool to standalone tests (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/coverage.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
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.
7 // This test is mainly here to ensure that the coverage tool compiles and
8 // runs.
9
10 import "dart:io";
11 import "dart:utf";
12
13 var coverageToolUrl = "tools/coverage.dart";
14 var coverageTargetUrl = "tests/language/hello_dart_test.dart";
kustermann 2013/05/31 13:41:28 Using paths relative to dart/ requires this script
kustermann 2013/05/31 13:41:28 These are not really urls. You could rename them t
hausner 2013/05/31 21:53:02 Done.
hausner 2013/05/31 21:53:02 Changed to use paths relative to the path of this
15 Process coverageToolProcess;
16 List sourceLines;
17 int nextLineToMatch = 0;
18
19 void onCoverageOutput(String line) {
20 print("COV: $line");
21 if (nextLineToMatch < sourceLines.length) {
22 if (line.endsWith(sourceLines[nextLineToMatch])) {
23 nextLineToMatch++;
kustermann 2013/05/31 13:41:28 If I see this correct, you actually don't verify t
hausner 2013/05/31 21:53:02 Correct. I just want to make sure the coverage too
24 }
25 }
26 }
27
28 void onCoverageExit(exitCode) {
29 var pid = coverageToolProcess.pid;
30 print("process $pid terminated with exit code $exitCode.");
31 if (nextLineToMatch < sourceLines.length) {
32 print("Error: could not match all source code lines "
33 "of '$coverageTargetUrl'");
34 exit(-1);
35 } else {
36 print("Successfully matched all lines of '$coverageTargetUrl'");
37 }
38 }
39
40 void main() {
41 var options = new Options();
42 var targetOpts = [ "--compile_all", coverageToolUrl, coverageTargetUrl ];
43
44 sourceLines = new File(Uri.parse(coverageTargetUrl).path).readAsLinesSync();
kustermann 2013/05/31 13:41:28 Uri.path will give you always forward slashes AFAI
hausner 2013/05/31 21:53:02 Done.
45 assert(sourceLines != null);
46
47 Process.start(options.executable, targetOpts).then((Process process) {
ricow1 2013/05/31 05:29:02 No need to use Process.start here, use Process.run
kustermann 2013/05/31 13:41:28 agreed.
hausner 2013/05/31 21:53:02 I don't know how I'd get to stdout and stderr of t
ricow1 2013/06/01 06:27:58 Process.run(bin, args).then((result) { print(res
48 coverageToolProcess = process;
49 coverageToolProcess.stdin.close();
50 var stdoutStringStream = coverageToolProcess.stdout
51 .transform(new StringDecoder())
52 .transform(new LineTransformer());
53 stdoutStringStream.listen(onCoverageOutput);
54
55 var stderrStringStream = coverageToolProcess.stderr
56 .transform(new StringDecoder())
57 .transform(new LineTransformer());
58 stderrStringStream.listen(onCoverageOutput);
59
60 coverageToolProcess.exitCode.then(onCoverageExit);
61 });
62 }
OLDNEW
« no previous file with comments | « no previous file | tools/coverage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698