1 from __future__
import absolute_import
12 from .lldbtest
import *
13 from . import lldbutil
15 if sys
.platform
.startswith('win32'):
16 # llvm.org/pr22274: need a pexpect replacement for windows
17 class PExpectTest(object):
22 class PExpectTest(TestBase
):
24 NO_DEBUG_INFO_TESTCASE
= True
27 def expect_prompt(self
):
28 self
.child
.expect_exact(self
.PROMPT
)
30 def launch(self
, executable
=None, extra_args
=None, timeout
=30, dimensions
=None):
31 logfile
= getattr(sys
.stdout
, 'buffer',
32 sys
.stdout
) if self
.TraceOn() else None
34 args
= ['--no-lldbinit', '--no-use-colors']
35 for cmd
in self
.setUpCommands():
37 if executable
is not None:
38 args
+= ['--file', executable
]
39 if extra_args
is not None:
40 args
.extend(extra_args
)
42 env
= dict(os
.environ
)
45 self
.child
= pexpect
.spawn(
46 lldbtest_config
.lldbExec
, args
=args
, logfile
=logfile
,
47 timeout
=timeout
, dimensions
=dimensions
, env
=env
)
49 for cmd
in self
.setUpCommands():
50 self
.child
.expect_exact(cmd
)
52 if executable
is not None:
53 self
.child
.expect_exact("target create")
54 self
.child
.expect_exact("Current executable set to")
57 def expect(self
, cmd
, substrs
=None):
58 self
.assertNotIn('\n', cmd
)
59 self
.child
.sendline(cmd
)
60 if substrs
is not None:
62 self
.child
.expect_exact(s
)
65 def quit(self
, gracefully
=True):
67 self
.child
.close(force
=not gracefully
)