OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 /// Helper program for running unit tests in warmed-up Dart VMs. | 5 /// Helper program for running unit tests in warmed-up Dart VMs. |
6 /// | 6 /// |
7 /// This program listens for JSON encoded messages on stdin (one message per | 7 /// This program listens for JSON encoded messages on stdin (one message per |
8 /// line) and prints out messages in response (also in JSON, one per line). | 8 /// line) and prints out messages in response (also in JSON, one per line). |
9 /// | 9 /// |
10 /// Messages are defined in 'message.dart'. | 10 /// Messages are defined in 'message.dart'. |
11 library fletch_tests.fletch_test_suite; | 11 library dartino_tests.dartino_test_suite; |
12 | 12 |
13 import 'dart:core' hide print; | 13 import 'dart:core' hide print; |
14 | 14 |
15 import 'dart:io'; | 15 import 'dart:io'; |
16 | 16 |
17 import 'dart:convert' show | 17 import 'dart:convert' show |
18 JSON, | 18 JSON, |
19 LineSplitter, | 19 LineSplitter, |
20 UTF8; | 20 UTF8; |
21 | 21 |
22 import 'dart:async' show | 22 import 'dart:async' show |
23 Completer, | 23 Completer, |
24 Future, | 24 Future, |
25 Stream, | 25 Stream, |
26 StreamIterator, | 26 StreamIterator, |
27 Zone, | 27 Zone, |
28 ZoneSpecification; | 28 ZoneSpecification; |
29 | 29 |
30 import 'dart:isolate'; | 30 import 'dart:isolate'; |
31 | 31 |
32 import 'package:fletchc/src/zone_helper.dart' show | 32 import 'package:dartino_compiler/src/zone_helper.dart' show |
33 runGuarded; | 33 runGuarded; |
34 | 34 |
35 import 'package:fletchc/src/hub/hub_main.dart' show | 35 import 'package:dartino_compiler/src/hub/hub_main.dart' show |
36 IsolatePool, | 36 IsolatePool, |
37 ManagedIsolate; | 37 ManagedIsolate; |
38 | 38 |
39 import 'package:fletchc/src/worker/developer.dart' show | 39 import 'package:dartino_compiler/src/worker/developer.dart' show |
40 configFileUri; | 40 configFileUri; |
41 | 41 |
42 import 'package:fletchc/src/console_print.dart' show | 42 import 'package:dartino_compiler/src/console_print.dart' show |
43 printToConsole; | 43 printToConsole; |
44 | 44 |
45 import 'messages.dart' show | 45 import 'messages.dart' show |
46 Info, | 46 Info, |
47 InternalErrorMessage, | 47 InternalErrorMessage, |
48 ListTests, | 48 ListTests, |
49 ListTestsReply, | 49 ListTestsReply, |
50 Message, | 50 Message, |
51 NamedMessage, | 51 NamedMessage, |
52 RunTest, | 52 RunTest, |
53 TestFailed, | 53 TestFailed, |
54 TestPassed, | 54 TestPassed, |
55 TestStdoutLine, | 55 TestStdoutLine, |
56 TimedOut, | 56 TimedOut, |
57 messageTransformer; | 57 messageTransformer; |
58 | 58 |
59 import 'all_tests.dart' show | 59 import 'all_tests.dart' show |
60 NoArgFuture, | 60 NoArgFuture, |
61 TESTS; | 61 TESTS; |
62 | 62 |
63 // TODO(ahe): Should be: "@@@STEP_FAILURE@@@". | 63 // TODO(ahe): Should be: "@@@STEP_FAILURE@@@". |
64 const String BUILDBOT_MARKER = "@@@STEP_WARNINGS@@@"; | 64 const String BUILDBOT_MARKER = "@@@STEP_WARNINGS@@@"; |
65 | 65 |
66 Map<String, NoArgFuture> expandedTests; | 66 Map<String, NoArgFuture> expandedTests; |
67 | 67 |
68 Sink<Message> messageSink; | 68 Sink<Message> messageSink; |
69 | 69 |
70 main() async { | 70 main() async { |
71 int port = const int.fromEnvironment("test.fletch_test_suite.port"); | 71 int port = const int.fromEnvironment("test.dartino_test_suite.port"); |
72 Socket socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, port); | 72 Socket socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, port); |
73 messageSink = new SocketSink(socket); | 73 messageSink = new SocketSink(socket); |
74 IsolatePool pool = new IsolatePool(isolateMain); | 74 IsolatePool pool = new IsolatePool(isolateMain); |
75 Set<ManagedIsolate> isolates = new Set<ManagedIsolate>(); | 75 Set<ManagedIsolate> isolates = new Set<ManagedIsolate>(); |
76 Map<String, RunningTest> runningTests = <String, RunningTest>{}; | 76 Map<String, RunningTest> runningTests = <String, RunningTest>{}; |
77 try { | 77 try { |
78 Stream<Message> messages = utf8Lines(socket).transform(messageTransformer); | 78 Stream<Message> messages = utf8Lines(socket).transform(messageTransformer); |
79 await for (Message message in messages) { | 79 await for (Message message in messages) { |
80 if (message is TimedOut) { | 80 if (message is TimedOut) { |
81 handleTimeout(message, runningTests); | 81 handleTimeout(message, runningTests); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 printLineOnStdout(String line) { | 210 printLineOnStdout(String line) { |
211 if (messageSink != null) { | 211 if (messageSink != null) { |
212 messageSink.add(new TestStdoutLine(name, line)); | 212 messageSink.add(new TestStdoutLine(name, line)); |
213 } else { | 213 } else { |
214 stdout.writeln(line); | 214 stdout.writeln(line); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 Future setupGlobalStateForTesting() async { | 218 Future setupGlobalStateForTesting() async { |
219 tmpdir = await Directory.systemTemp.createTemp("fletch_test_home"); | 219 tmpdir = await Directory.systemTemp.createTemp("dartino_test_home"); |
220 configFileUri = tmpdir.uri.resolve('.fletch'); | 220 configFileUri = tmpdir.uri.resolve('.dartino'); |
221 printToConsole = printLineOnStdout; | 221 printToConsole = printLineOnStdout; |
222 } | 222 } |
223 | 223 |
224 Future resetGlobalStateAfterTesting() async { | 224 Future resetGlobalStateAfterTesting() async { |
225 try { | 225 try { |
226 await tmpdir.delete(recursive: true); | 226 await tmpdir.delete(recursive: true); |
227 } on FileSystemException catch (e) { | 227 } on FileSystemException catch (e) { |
228 printToConsole('Error when deleting $tmpdir: $e'); | 228 printToConsole('Error when deleting $tmpdir: $e'); |
229 } | 229 } |
230 printToConsole = Zone.ROOT.print; | 230 printToConsole = Zone.ROOT.print; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 PortSink(this.port); | 307 PortSink(this.port); |
308 | 308 |
309 void add(Message message) { | 309 void add(Message message) { |
310 port.send(message); | 310 port.send(message); |
311 } | 311 } |
312 | 312 |
313 void close() { | 313 void close() { |
314 throw "not supported"; | 314 throw "not supported"; |
315 } | 315 } |
316 } | 316 } |
OLD | NEW |