diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbpexpect.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbpexpect.py | 97 |
1 files changed, 31 insertions, 66 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py index ce73654bdbe..bb50f47e02e 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py @@ -13,82 +13,47 @@ from .lldbtest import * from . import lldbutil if sys.platform.startswith('win32'): - class PExpectTest(TestBase): + # llvm.org/pr22274: need a pexpect replacement for windows + class PExpectTest(object): pass else: import pexpect class PExpectTest(TestBase): - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - TestBase.setUp(self) + NO_DEBUG_INFO_TESTCASE = True + PROMPT = "(lldb) " - def launchArgs(self): - return "" + def expect_prompt(self): + self.child.expect_exact(self.PROMPT) - def launch(self, timeout=None): - if timeout is None: - timeout = 30 + def launch(self, executable=None, timeout=30, dimensions=None): logfile = sys.stdout if self.TraceOn() else None + args = ['--no-lldbinit', '--no-use-colors'] + for cmd in self.setUpCommands(): + args += ['-O', cmd] + if executable is not None: + args += ['--file', executable] self.child = pexpect.spawn( - '%s --no-use-colors %s' % - (lldbtest_config.lldbExec, self.launchArgs()), logfile=logfile) - self.child.timeout = timeout - self.timeout = timeout - - def expect(self, patterns=None, timeout=None, exact=None): - if patterns is None: - return None - if timeout is None: - timeout = self.timeout - if exact is None: - exact = False - if exact: - return self.child.expect_exact(patterns, timeout=timeout) - else: - return self.child.expect(patterns, timeout=timeout) - - def expectall(self, patterns=None, timeout=None, exact=None): - if patterns is None: - return None - if timeout is None: - timeout = self.timeout - if exact is None: - exact = False - for pattern in patterns: - self.expect(pattern, timeout=timeout, exact=exact) - - def sendimpl( - self, - sender, - command, - patterns=None, - timeout=None, - exact=None): - sender(command) - return self.expect(patterns=patterns, timeout=timeout, exact=exact) - - def send(self, command, patterns=None, timeout=None, exact=None): - return self.sendimpl( - self.child.send, - command, - patterns, - timeout, - exact) - - def sendline(self, command, patterns=None, timeout=None, exact=None): - return self.sendimpl( - self.child.sendline, - command, - patterns, - timeout, - exact) - - def quit(self, gracefully=None): - if gracefully is None: - gracefully = True + lldbtest_config.lldbExec, args=args, logfile=logfile, + timeout=timeout, dimensions=dimensions) + self.expect_prompt() + for cmd in self.setUpCommands(): + self.child.expect_exact(cmd) + self.expect_prompt() + if executable is not None: + self.child.expect_exact("target create") + self.child.expect_exact("Current executable set to") + self.expect_prompt() + + def expect(self, cmd, substrs=None): + self.child.sendline(cmd) + if substrs is not None: + for s in substrs: + self.child.expect_exact(s) + self.expect_prompt() + + def quit(self, gracefully=True): self.child.sendeof() self.child.close(force=not gracefully) self.child = None |