OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async' show | 5 import 'dart:async' show |
6 Future, | 6 Future, |
7 StreamIterator; | 7 StreamIterator; |
8 | 8 |
9 import 'dart:convert' show | 9 import 'dart:convert' show |
10 LineSplitter, | 10 LineSplitter, |
11 UTF8; | 11 UTF8; |
12 | 12 |
13 import 'dart:io' show | 13 import 'dart:io' show |
14 Process, | 14 Process, |
15 ProcessSignal; | 15 ProcessSignal; |
16 | 16 |
17 import 'package:expect/expect.dart' show | 17 import 'package:expect/expect.dart' show |
18 Expect; | 18 Expect; |
19 | 19 |
20 import 'cli_tests.dart' show | 20 import 'cli_tests.dart' show |
21 CliTest, | 21 CliTest, |
22 thisDirectory; | 22 thisDirectory; |
23 | 23 |
24 import 'prompt_splitter.dart' show | 24 import 'prompt_splitter.dart' show |
25 PromptSplitter; | 25 PromptSplitter; |
26 | 26 |
27 import 'package:fletchc/src/hub/exit_codes.dart' show | 27 import 'package:dartino_compiler/src/hub/exit_codes.dart' show |
28 DART_VM_EXITCODE_UNCAUGHT_EXCEPTION; | 28 DART_VM_EXITCODE_UNCAUGHT_EXCEPTION; |
29 | 29 |
30 final List<CliTest> tests = <CliTest>[ | 30 final List<CliTest> tests = <CliTest>[ |
31 new DebuggerInterruptTest(), | 31 new DebuggerInterruptTest(), |
32 new DebuggerListProcessesTest(), | 32 new DebuggerListProcessesTest(), |
33 new DebuggerRelativeFileReferenceTest(), | 33 new DebuggerRelativeFileReferenceTest(), |
34 new DebuggerStepInLoopTest(), | 34 new DebuggerStepInLoopTest(), |
35 new DebuggerRerunThrowingProgramTest(), | 35 new DebuggerRerunThrowingProgramTest(), |
36 ]; | 36 ]; |
37 | 37 |
38 abstract class InteractiveDebuggerTest extends CliTest { | 38 abstract class InteractiveDebuggerTest extends CliTest { |
39 final String testFilePath; | 39 final String testFilePath; |
40 final String workingDirectory; | 40 final String workingDirectory; |
41 Process process; | 41 Process process; |
42 StreamIterator out; | 42 StreamIterator out; |
43 StreamIterator err; | 43 StreamIterator err; |
44 | 44 |
45 InteractiveDebuggerTest(String name) | 45 InteractiveDebuggerTest(String name) |
46 : super(name), | 46 : super(name), |
47 testFilePath = thisDirectory.resolve("$name.dart").toFilePath(); | 47 testFilePath = thisDirectory.resolve("$name.dart").toFilePath(); |
48 | 48 |
49 Future<Null> internalRun(); | 49 Future<Null> internalRun(); |
50 | 50 |
51 Future<Null> run() async { | 51 Future<Null> run() async { |
52 process = await fletch(["debug", testFilePath], | 52 process = await dartino(["debug", testFilePath], |
53 workingDirectory: workingDirectory); | 53 workingDirectory: workingDirectory); |
54 out = new StreamIterator( | 54 out = new StreamIterator( |
55 process.stdout.transform(UTF8.decoder).transform(new PromptSplitter())); | 55 process.stdout.transform(UTF8.decoder).transform(new PromptSplitter())); |
56 err = new StreamIterator( | 56 err = new StreamIterator( |
57 process.stderr.transform(UTF8.decoder).transform(new LineSplitter())); | 57 process.stderr.transform(UTF8.decoder).transform(new LineSplitter())); |
58 try { | 58 try { |
59 await expectPrompt("Debug header"); | 59 await expectPrompt("Debug header"); |
60 await internalRun(); | 60 await internalRun(); |
61 } finally { | 61 } finally { |
62 process.stdin.close(); | 62 process.stdin.close(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 await runCommandAndExpectPrompt("lp"); | 150 await runCommandAndExpectPrompt("lp"); |
151 await runCommandAndExpectPrompt("c"); | 151 await runCommandAndExpectPrompt("c"); |
152 await runCommandAndExpectPrompt("lp"); | 152 await runCommandAndExpectPrompt("lp"); |
153 await runCommandAndExpectPrompt("c"); | 153 await runCommandAndExpectPrompt("c"); |
154 await expectExitCode(0); | 154 await expectExitCode(0); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 class DebuggerRelativeFileReferenceTest extends InteractiveDebuggerTest { | 158 class DebuggerRelativeFileReferenceTest extends InteractiveDebuggerTest { |
159 | 159 |
160 // Working directory that is not the fletch-root directory. | 160 // Working directory that is not the dartino-root directory. |
161 final String workingDirectory = "$thisDirectory/../"; | 161 final String workingDirectory = "$thisDirectory/../"; |
162 | 162 |
163 // Relative reference to the test file. | 163 // Relative reference to the test file. |
164 final String testFilePath = "cli_tests/debugger_relative_file_reference.dart"; | 164 final String testFilePath = "cli_tests/debugger_relative_file_reference.dart"; |
165 | 165 |
166 DebuggerRelativeFileReferenceTest() | 166 DebuggerRelativeFileReferenceTest() |
167 : super("debugger_relative_file_reference"); | 167 : super("debugger_relative_file_reference"); |
168 | 168 |
169 Future<Null> internalRun() async { | 169 Future<Null> internalRun() async { |
170 await runCommandAndExpectPrompt("bf $testFilePath 13"); | 170 await runCommandAndExpectPrompt("bf $testFilePath 13"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 main(List<String> args) async { | 210 main(List<String> args) async { |
211 for (CliTest test in tests) { | 211 for (CliTest test in tests) { |
212 if (args.any((arg) => test.name.indexOf(arg) >= 0)) { | 212 if (args.any((arg) => test.name.indexOf(arg) >= 0)) { |
213 await test.run(); | 213 await test.run(); |
214 } | 214 } |
215 } | 215 } |
216 } | 216 } |
OLD | NEW |