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 /// Modify this file to include more tests. | 5 /// Modify this file to include more tests. |
6 library fletch_tests.debugger; | 6 library dartino_tests.debugger; |
7 | 7 |
8 import 'dart:async' show | 8 import 'dart:async' show |
9 Stream, | 9 Stream, |
10 Future; | 10 Future; |
11 | 11 |
12 import 'dart:convert' show | 12 import 'dart:convert' show |
13 UTF8; | 13 UTF8; |
14 | 14 |
15 import 'dart:io' show | 15 import 'dart:io' show |
16 Directory, | 16 Directory, |
17 FileSystemEntity, | 17 FileSystemEntity, |
18 FileSystemException, | 18 FileSystemException, |
19 File; | 19 File; |
20 | 20 |
21 import 'package:expect/expect.dart' show | 21 import 'package:expect/expect.dart' show |
22 Expect; | 22 Expect; |
23 | 23 |
24 import 'package:fletchc/src/verbs/infrastructure.dart' show | 24 import 'package:dartino_compiler/src/verbs/infrastructure.dart' show |
25 fileUri; | 25 fileUri; |
26 | 26 |
27 import 'package:fletchc/src/hub/session_manager.dart'; | 27 import 'package:dartino_compiler/src/hub/session_manager.dart'; |
28 | 28 |
29 import 'package:fletchc/src/worker/developer.dart'; | 29 import 'package:dartino_compiler/src/worker/developer.dart'; |
30 | 30 |
31 const String testLocation = 'tests/debugger'; | 31 const String testLocation = 'tests/debugger'; |
32 const String generatedTestLocation = 'tests/debugger_generated'; | 32 const String generatedTestLocation = 'tests/debugger_generated'; |
33 | 33 |
34 typedef Future NoArgFuture(); | 34 typedef Future NoArgFuture(); |
35 | 35 |
36 Future runTest(String name, Uri uri, bool writeGoldenFiles) async { | 36 Future runTest(String name, Uri uri, bool writeGoldenFiles) async { |
37 print("$name: $uri"); | 37 print("$name: $uri"); |
38 Settings settings = new Settings( | 38 Settings settings = new Settings( |
39 fileUri(".packages", Uri.base), | 39 fileUri(".packages", Uri.base), |
(...skipping 13 matching lines...) Expand all Loading... |
53 state.session.hideRawIds = true; | 53 state.session.hideRawIds = true; |
54 state.session.colorsDisabled = true; | 54 state.session.colorsDisabled = true; |
55 | 55 |
56 List<int> output = <int>[]; | 56 List<int> output = <int>[]; |
57 | 57 |
58 state.stdoutSink.attachCommandSender(output.addAll); | 58 state.stdoutSink.attachCommandSender(output.addAll); |
59 state.stderrSink.attachCommandSender(output.addAll); | 59 state.stderrSink.attachCommandSender(output.addAll); |
60 | 60 |
61 List<String> debuggerCommands = <String>[]; | 61 List<String> debuggerCommands = <String>[]; |
62 for (String line in await new File.fromUri(uri).readAsLines()) { | 62 for (String line in await new File.fromUri(uri).readAsLines()) { |
63 const String commandsPattern = "// FletchDebuggerCommands="; | 63 const String commandsPattern = "// DartinoDebuggerCommands="; |
64 if (line.startsWith(commandsPattern)) { | 64 if (line.startsWith(commandsPattern)) { |
65 debuggerCommands = line.substring(commandsPattern.length).split(","); | 65 debuggerCommands = line.substring(commandsPattern.length).split(","); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 Expect.equals(0, await run(state, testDebuggerCommands: debuggerCommands)); | 69 Expect.equals(0, await run(state, testDebuggerCommands: debuggerCommands)); |
70 | 70 |
71 int exitCode = await state.fletchVm.exitCode; | 71 int exitCode = await state.dartinoVm.exitCode; |
72 | 72 |
73 state.stdoutSink.detachCommandSender(); | 73 state.stdoutSink.detachCommandSender(); |
74 state.stderrSink.detachCommandSender(); | 74 state.stderrSink.detachCommandSender(); |
75 | 75 |
76 if (exitCode != 0) { | 76 if (exitCode != 0) { |
77 output.addAll( | 77 output.addAll( |
78 UTF8.encode("Non-zero exit code from 'fletch-vm' ($exitCode).\n")); | 78 UTF8.encode("Non-zero exit code from 'dartino-vm' ($exitCode).\n")); |
79 } | 79 } |
80 | 80 |
81 String expectationsFile = | 81 String expectationsFile = |
82 name.substring(0, name.length - "_test".length) + "_expected.txt"; | 82 name.substring(0, name.length - "_test".length) + "_expected.txt"; |
83 if (!writeGoldenFiles) { | 83 if (!writeGoldenFiles) { |
84 Uri expectationsUri = uri.resolve(expectationsFile); | 84 Uri expectationsUri = uri.resolve(expectationsFile); |
85 String expectations = | 85 String expectations = |
86 await new File.fromUri(expectationsUri).readAsString(); | 86 await new File.fromUri(expectationsUri).readAsString(); |
87 | 87 |
88 Expect.stringEquals( | 88 Expect.stringEquals( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return listTestsInternal(false); | 136 return listTestsInternal(false); |
137 } | 137 } |
138 | 138 |
139 main(List<String> args) async { | 139 main(List<String> args) async { |
140 args = args.map((a) => 'debugger/$a'); | 140 args = args.map((a) => 'debugger/$a'); |
141 Map<String, NoArgFuture> tests = await listTestsInternal(true); | 141 Map<String, NoArgFuture> tests = await listTestsInternal(true); |
142 for (String name in tests.keys) { | 142 for (String name in tests.keys) { |
143 if (args.isEmpty || args.contains(name)) await tests[name](); | 143 if (args.isEmpty || args.contains(name)) await tests[name](); |
144 } | 144 } |
145 } | 145 } |
OLD | NEW |