@@ -90,11 +90,14 @@ void main () {
9090 logger = BufferLogger .test ();
9191 });
9292
93- testWithoutContext ('debugger attached' , () async {
93+ testWithoutContext ('debugger attached and stopped' , () async {
94+ final StreamController <List <int >> stdin = StreamController <List <int >>();
95+ final Stream <String > stdinStream = stdin.stream.transform <String >(const Utf8Decoder ());
9496 final FakeProcessManager processManager = FakeProcessManager .list (< FakeCommand > [
95- const FakeCommand (
96- command: < String > ['ios-deploy' ],
97- stdout: '(lldb) run\r\n success\r\n success\r\n Log on attach1\r\n\r\n Log on attach2\r\n\r\n\r\n\r\n PROCESS_STOPPED\r\n Log after process exit' ,
97+ FakeCommand (
98+ command: const < String > ['ios-deploy' ],
99+ stdout: "(lldb) run\r\n success\r\n success\r\n Log on attach1\r\n\r\n Log on attach2\r\n\r\n\r\n\r\n PROCESS_STOPPED\r\n Log after process stop\r\n thread backtrace all\r\n * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP" ,
100+ stdin: IOSink (stdin.sink),
98101 ),
99102 ]);
100103 final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger .test (
@@ -113,7 +116,15 @@ void main () {
113116 'Log on attach2' ,
114117 '' ,
115118 '' ,
116- 'Log after process exit' ,
119+ 'Log after process stop'
120+ ]);
121+ expect (logger.traceText, contains ('PROCESS_STOPPED' ));
122+ expect (logger.traceText, contains ('thread backtrace all' ));
123+ expect (logger.traceText, contains ('* thread #1' ));
124+ expect (await stdinStream.take (3 ).toList (), < String > [
125+ 'thread backtrace all' ,
126+ '\n ' ,
127+ 'process detach' ,
117128 ]);
118129 });
119130
@@ -141,11 +152,14 @@ void main () {
141152 });
142153
143154 testWithoutContext ('app crash' , () async {
155+ final StreamController <List <int >> stdin = StreamController <List <int >>();
156+ final Stream <String > stdinStream = stdin.stream.transform <String >(const Utf8Decoder ());
144157 final FakeProcessManager processManager = FakeProcessManager .list (< FakeCommand > [
145- const FakeCommand (
146- command: < String > ['ios-deploy' ],
158+ FakeCommand (
159+ command: const < String > ['ios-deploy' ],
147160 stdout:
148- '(lldb) run\r\n success\r\n Log on attach\r\n (lldb) Process 6156 stopped\r\n * thread #1, stop reason = Assertion failed:' ,
161+ '(lldb) run\r\n success\r\n Log on attach\r\n (lldb) Process 6156 stopped\r\n * thread #1, stop reason = Assertion failed:\r\n thread backtrace all\r\n * thread #1, stop reason = Assertion failed:' ,
162+ stdin: IOSink (stdin.sink),
149163 ),
150164 ]);
151165 final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger .test (
@@ -162,6 +176,14 @@ void main () {
162176 'Log on attach' ,
163177 '* thread #1, stop reason = Assertion failed:' ,
164178 ]);
179+ expect (logger.traceText, contains ('Process 6156 stopped' ));
180+ expect (logger.traceText, contains ('thread backtrace all' ));
181+ expect (logger.traceText, contains ('* thread #1' ));
182+ expect (await stdinStream.take (3 ).toList (), < String > [
183+ 'thread backtrace all' ,
184+ '\n ' ,
185+ 'process detach' ,
186+ ]);
165187 });
166188
167189 testWithoutContext ('attach failed' , () async {
@@ -268,6 +290,31 @@ void main () {
268290 iosDeployDebugger.detach ();
269291 expect (await stdinStream.first, 'process detach' );
270292 });
293+
294+ testWithoutContext ('stop with backtrace' , () async {
295+ final StreamController <List <int >> stdin = StreamController <List <int >>();
296+ final Stream <String > stdinStream = stdin.stream.transform <String >(const Utf8Decoder ());
297+ final FakeProcessManager processManager = FakeProcessManager .list (< FakeCommand > [
298+ FakeCommand (
299+ command: const < String > [
300+ 'ios-deploy' ,
301+ ],
302+ stdout:
303+ '(lldb) run\n success\n Log on attach\n (lldb) Process 6156 stopped\n * thread #1, stop reason = Assertion failed:\n (lldb) Process 6156 detached' ,
304+ stdin: IOSink (stdin.sink),
305+ ),
306+ ]);
307+ final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger .test (
308+ processManager: processManager,
309+ );
310+ await iosDeployDebugger.launchAndAttach ();
311+ await iosDeployDebugger.stopAndDumpBacktrace ();
312+ expect (await stdinStream.take (3 ).toList (), < String > [
313+ 'thread backtrace all' ,
314+ '\n ' ,
315+ 'process detach' ,
316+ ]);
317+ });
271318 });
272319
273320 group ('IOSDeploy.uninstallApp' , () {
0 commit comments