Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / repl / clang / TestClangREPL.py
blob0b67955a7833c65284a81b8f939ddf6d17bf28ba
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test.lldbpexpect import PExpectTest
7 class TestCase(PExpectTest):
8 def expect_repl(self, expr, substrs=[]):
9 """Evaluates the expression in the REPL and verifies that the list
10 of substrs is in the REPL output."""
11 # Only single line expressions supported.
12 self.assertNotIn("\n", expr)
13 self.child.send(expr + "\n")
14 for substr in substrs:
15 self.child.expect_exact(substr)
16 # Look for the start of the next REPL input line.
17 self.current_repl_line_number += 1
18 self.child.expect_exact(str(self.current_repl_line_number) + ">")
20 # PExpect uses many timeouts internally and doesn't play well
21 # under ASAN on a loaded machine..
22 @skipIfAsan
23 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on buildbot
24 @skipIfEditlineSupportMissing
25 def test_basic_completion(self):
26 """Test that we can complete a simple multiline expression"""
27 self.build()
28 self.current_repl_line_number = 1
30 self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))
31 # Try launching the REPL before we have a running target.
32 self.expect(
33 "expression --repl -l c --",
34 substrs=["REPL requires a running target process."],
37 self.expect("b main", substrs=["Breakpoint 1", "address ="])
38 self.expect("run", substrs=["stop reason = breakpoint 1"])
40 # Start the REPL.
41 self.child.send("expression --repl -l c --\n")
42 self.child.expect_exact("1>")
44 # Try evaluating a simple expression.
45 self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])
47 # Try declaring a persistent variable.
48 self.expect_repl(
49 "long $persistent = 7; 5",
50 substrs=["(int) $1 = 5", "(long) $persistent = 7"],
53 # Try using the persistent variable from before.
54 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
56 self.quit()