|
13 | 13 | from . import lldbutil
|
14 | 14 | from lldbsuite.test.decorators import *
|
15 | 15 |
|
16 |
| -if sys.platform.startswith('win32'): |
17 |
| - # llvm.org/pr22274: need a pexpect replacement for windows |
18 |
| - class PExpectTest(object): |
19 |
| - pass |
20 |
| -else: |
21 |
| - import pexpect |
| 16 | +@skipIfRemote |
| 17 | +@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows |
| 18 | +class PExpectTest(TestBase): |
22 | 19 |
|
23 |
| - @skipIfRemote |
24 |
| - class PExpectTest(TestBase): |
| 20 | + NO_DEBUG_INFO_TESTCASE = True |
| 21 | + PROMPT = "(lldb) " |
25 | 22 |
|
26 |
| - NO_DEBUG_INFO_TESTCASE = True |
27 |
| - PROMPT = "(lldb) " |
| 23 | + def expect_prompt(self): |
| 24 | + self.child.expect_exact(self.PROMPT) |
28 | 25 |
|
29 |
| - def expect_prompt(self): |
30 |
| - self.child.expect_exact(self.PROMPT) |
| 26 | + def launch(self, executable=None, extra_args=None, timeout=30, dimensions=None): |
| 27 | + logfile = getattr(sys.stdout, 'buffer', |
| 28 | + sys.stdout) if self.TraceOn() else None |
31 | 29 |
|
32 |
| - def launch(self, executable=None, extra_args=None, timeout=30, dimensions=None): |
33 |
| - logfile = getattr(sys.stdout, 'buffer', |
34 |
| - sys.stdout) if self.TraceOn() else None |
| 30 | + args = ['--no-lldbinit', '--no-use-colors'] |
| 31 | + for cmd in self.setUpCommands(): |
| 32 | + args += ['-O', cmd] |
| 33 | + if executable is not None: |
| 34 | + args += ['--file', executable] |
| 35 | + if extra_args is not None: |
| 36 | + args.extend(extra_args) |
35 | 37 |
|
36 |
| - args = ['--no-lldbinit', '--no-use-colors'] |
37 |
| - for cmd in self.setUpCommands(): |
38 |
| - args += ['-O', cmd] |
39 |
| - if executable is not None: |
40 |
| - args += ['--file', executable] |
41 |
| - if extra_args is not None: |
42 |
| - args.extend(extra_args) |
| 38 | + env = dict(os.environ) |
| 39 | + env["TERM"]="vt100" |
43 | 40 |
|
44 |
| - env = dict(os.environ) |
45 |
| - env["TERM"]="vt100" |
46 |
| - |
47 |
| - self.child = pexpect.spawn( |
48 |
| - lldbtest_config.lldbExec, args=args, logfile=logfile, |
49 |
| - timeout=timeout, dimensions=dimensions, env=env) |
| 41 | + import pexpect |
| 42 | + self.child = pexpect.spawn( |
| 43 | + lldbtest_config.lldbExec, args=args, logfile=logfile, |
| 44 | + timeout=timeout, dimensions=dimensions, env=env) |
| 45 | + self.expect_prompt() |
| 46 | + for cmd in self.setUpCommands(): |
| 47 | + self.child.expect_exact(cmd) |
50 | 48 | self.expect_prompt()
|
51 |
| - for cmd in self.setUpCommands(): |
52 |
| - self.child.expect_exact(cmd) |
53 |
| - self.expect_prompt() |
54 |
| - if executable is not None: |
55 |
| - self.child.expect_exact("target create") |
56 |
| - self.child.expect_exact("Current executable set to") |
57 |
| - self.expect_prompt() |
58 |
| - |
59 |
| - def expect(self, cmd, substrs=None): |
60 |
| - self.assertNotIn('\n', cmd) |
61 |
| - self.child.sendline(cmd) |
62 |
| - if substrs is not None: |
63 |
| - for s in substrs: |
64 |
| - self.child.expect_exact(s) |
| 49 | + if executable is not None: |
| 50 | + self.child.expect_exact("target create") |
| 51 | + self.child.expect_exact("Current executable set to") |
65 | 52 | self.expect_prompt()
|
66 | 53 |
|
67 |
| - def quit(self, gracefully=True): |
68 |
| - self.child.sendeof() |
69 |
| - self.child.close(force=not gracefully) |
70 |
| - self.child = None |
| 54 | + def expect(self, cmd, substrs=None): |
| 55 | + self.assertNotIn('\n', cmd) |
| 56 | + self.child.sendline(cmd) |
| 57 | + if substrs is not None: |
| 58 | + for s in substrs: |
| 59 | + self.child.expect_exact(s) |
| 60 | + self.expect_prompt() |
| 61 | + |
| 62 | + def quit(self, gracefully=True): |
| 63 | + self.child.sendeof() |
| 64 | + self.child.close(force=not gracefully) |
| 65 | + self.child = None |
71 | 66 |
|
72 |
| - def cursor_forward_escape_seq(self, chars_to_move): |
73 |
| - """ |
74 |
| - Returns the escape sequence to move the cursor forward/right |
75 |
| - by a certain amount of characters. |
76 |
| - """ |
77 |
| - return b"\x1b\[" + str(chars_to_move).encode("utf-8") + b"C" |
| 67 | + def cursor_forward_escape_seq(self, chars_to_move): |
| 68 | + """ |
| 69 | + Returns the escape sequence to move the cursor forward/right |
| 70 | + by a certain amount of characters. |
| 71 | + """ |
| 72 | + return b"\x1b\[" + str(chars_to_move).encode("utf-8") + b"C" |
0 commit comments