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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 11091070: Change Process.start to return a future that completes with a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Classes and methods for enumerating and preparing tests. 6 * Classes and methods for enumerating and preparing tests.
7 * 7 *
8 * This library includes: 8 * This library includes:
9 * 9 *
10 * - Creating tests by listing all the Dart files in certain directories, 10 * - Creating tests by listing all the Dart files in certain directories,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]); 58 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]);
59 } 59 }
60 60
61 61
62 // TODO(1030): remove once in the corelib. 62 // TODO(1030): remove once in the corelib.
63 bool Contains(element, collection) => collection.indexOf(element) >= 0; 63 bool Contains(element, collection) => collection.indexOf(element) >= 0;
64 64
65 65
66 void ccTestLister() { 66 void ccTestLister() {
67 port.receive((String runnerPath, SendPort replyTo) { 67 port.receive((String runnerPath, SendPort replyTo) {
68 var p = Process.start(runnerPath, ["--list"]); 68 void processErrorHandler(error) {
69 StringInputStream stdoutStream = new StringInputStream(p.stdout);
70 List<String> tests = new List<String>();
71 stdoutStream.onLine = () {
72 String line = stdoutStream.readLine();
73 while (line != null) {
74 tests.add(line);
75 line = stdoutStream.readLine();
76 }
77 };
78 p.onError = (error) {
79 print("Failed to list tests: $runnerPath --list"); 69 print("Failed to list tests: $runnerPath --list");
80 replyTo.send(""); 70 replyTo.send("");
81 }; 71 }
82 p.onExit = (code) { 72 Future processFuture = Process.start(runnerPath, ["--list"]);
83 if (code < 0) { 73 processFuture.then((p) {
84 print("Failed to list tests: $runnerPath --list"); 74 StringInputStream stdoutStream = new StringInputStream(p.stdout);
75 List<String> tests = new List<String>();
76 stdoutStream.onLine = () {
77 String line = stdoutStream.readLine();
78 while (line != null) {
79 tests.add(line);
80 line = stdoutStream.readLine();
81 }
82 };
83 p.onError = processErrorHandler;
84 p.onExit = (code) {
85 if (code < 0) {
86 print("Failed to list tests: $runnerPath --list");
87 replyTo.send("");
88 }
89 for (String test in tests) {
90 replyTo.send(test);
91 }
85 replyTo.send(""); 92 replyTo.send("");
86 } 93 };
87 for (String test in tests) { 94 port.close();
88 replyTo.send(test); 95 });
89 } 96 processFuture.handleException((e) {
90 replyTo.send(""); 97 processErrorHandler(e);
91 }; 98 return true;
92 port.close(); 99 });
Søren Gjesse 2012/10/12 07:47:22 This code is now 7 lines longer...
Mads Ager (google) 2012/10/12 08:44:46 I know. I removed onError on process. That means t
93 }); 100 });
94 } 101 }
95 102
96 103
97 /** 104 /**
98 * A specialized [TestSuite] that runs tests written in C to unit test 105 * A specialized [TestSuite] that runs tests written in C to unit test
99 * the Dart virtual machine and its API. 106 * the Dart virtual machine and its API.
100 * 107 *
101 * The tests are compiled into a monolithic executable by the build step. 108 * The tests are compiled into a monolithic executable by the build step.
102 * The executable lists its tests when run with the --list command line flag. 109 * The executable lists its tests when run with the --list command line flag.
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 * $noCrash tests are expected to be flaky but not crash 1474 * $noCrash tests are expected to be flaky but not crash
1468 * $pass tests are expected to pass 1475 * $pass tests are expected to pass
1469 * $failOk tests are expected to fail that we won't fix 1476 * $failOk tests are expected to fail that we won't fix
1470 * $fail tests are expected to fail that we should fix 1477 * $fail tests are expected to fail that we should fix
1471 * $crash tests are expected to crash that we should fix 1478 * $crash tests are expected to crash that we should fix
1472 * $timeout tests are allowed to timeout 1479 * $timeout tests are allowed to timeout
1473 """; 1480 """;
1474 print(report); 1481 print(report);
1475 } 1482 }
1476 } 1483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698