summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-03-09 10:39:40 +0000
committerPavel Labath <labath@google.com>2018-03-09 10:39:40 +0000
commit5f56fca4e10ab421775e155b669608d8c49cd5fd (patch)
tree5e51a1ea841d8722df69123e74cb89639279c713 /lldb/packages/Python/lldbsuite
parent6b62039bb0c035bea854d68a86394d42fb15256b (diff)
downloadbcm5719-llvm-5f56fca4e10ab421775e155b669608d8c49cd5fd.tar.gz
bcm5719-llvm-5f56fca4e10ab421775e155b669608d8c49cd5fd.zip
Move option parsing out of the Args class
Summary: The args class is used in plenty of places (a lot of them in the lower lldb layers) for representing a list of arguments, and most of these places don't care about option parsing. Moving the option parsing out of the class removes the largest external dependency (there are a couple more, but these are in static functions), and brings us closer to being able to move it to the Utility module). The new home for these functions is the Options class, which was already used as an argument to the parse calls, so this just inverts the dependency between the two. The functions are themselves are mainly just copied -- the biggest functional change I've made to them is to avoid modifying the input Args argument (getopt likes to permute the argument vector), as it was weird to have another class reorder the entries in Args class. So now the functions don't modify the input arguments, and (for those where it makes sense) return a new Args vector instead. I've also made the addition of a "fake arg0" (required for getopt compatibility) an implementation detail rather than a part of interface. While doing that I noticed that ParseForCompletion function was recording the option indexes in the shuffled vector, but then the consumer was looking up the entries in the unshuffled one. This manifested itself as us not being able to complete "watchpoint set variable foo --" (because getopt would move "foo" to the end). Surprisingly all other completions (e.g. "watchpoint set variable foo --w") were not affected by this. However, I couldn't find a comprehensive test for command argument completion, so I consolidated the existing tests and added a bunch of new ones. Reviewers: davide, jingham, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D43837 llvm-svn: 327110
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py47
1 files changed, 21 insertions, 26 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py b/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
index 4522312f824..b1ad3db8e67 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -88,23 +88,6 @@ class CommandLineCompletionTestCase(TestBase):
@expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
@skipIfFreeBSD # timing out on the FreeBSD buildbot
@no_debug_info_test
- def test_watchpoint_set_variable_dash_w(self):
- """Test that 'watchpoint set variable -w' completes to 'watchpoint set variable -w '."""
- self.complete_from_to(
- 'watchpoint set variable -w',
- 'watchpoint set variable -w ')
-
- @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
- @skipIfFreeBSD # timing out on the FreeBSD buildbot
- @no_debug_info_test
- def test_watchpoint_set_variable_dash_w_space(self):
- """Test that 'watchpoint set variable -w ' completes to ['read', 'write', 'read_write']."""
- self.complete_from_to('watchpoint set variable -w ',
- ['read', 'write', 'read_write'])
-
- @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
- @skipIfFreeBSD # timing out on the FreeBSD buildbot
- @no_debug_info_test
def test_watchpoint_set_ex(self):
"""Test that 'watchpoint set ex' completes to 'watchpoint set expression '."""
self.complete_from_to(
@@ -121,15 +104,6 @@ class CommandLineCompletionTestCase(TestBase):
@expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
@skipIfFreeBSD # timing out on the FreeBSD buildbot
@no_debug_info_test
- def test_watchpoint_set_variable_dash_w_read_underbar(self):
- """Test that 'watchpoint set variable -w read_' completes to 'watchpoint set variable -w read_write'."""
- self.complete_from_to(
- 'watchpoint set variable -w read_',
- 'watchpoint set variable -w read_write')
-
- @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
- @skipIfFreeBSD # timing out on the FreeBSD buildbot
- @no_debug_info_test
def test_help_fi(self):
"""Test that 'help fi' completes to ['file', 'finish']."""
self.complete_from_to(
@@ -296,6 +270,27 @@ class CommandLineCompletionTestCase(TestBase):
"""Test that 'target va' completes to 'target variable '."""
self.complete_from_to('target va', 'target variable ')
+ def test_command_argument_completion(self):
+ """Test completion of command arguments"""
+ self.complete_from_to("watchpoint set variable -", ["-w", "-s"])
+ self.complete_from_to('watchpoint set variable -w', 'watchpoint set variable -w ')
+ self.complete_from_to("watchpoint set variable --", ["--watch", "--size"])
+ self.complete_from_to("watchpoint set variable --w", "watchpoint set variable --watch")
+ self.complete_from_to('watchpoint set variable -w ', ['read', 'write', 'read_write'])
+ self.complete_from_to("watchpoint set variable --watch ", ["read", "write", "read_write"])
+ self.complete_from_to("watchpoint set variable --watch w", "watchpoint set variable --watch write")
+ self.complete_from_to('watchpoint set variable -w read_', 'watchpoint set variable -w read_write')
+ # Now try the same thing with a variable name (non-option argument) to
+ # test that getopts arg reshuffling doesn't confuse us.
+ self.complete_from_to("watchpoint set variable foo -", ["-w", "-s"])
+ self.complete_from_to('watchpoint set variable foo -w', 'watchpoint set variable foo -w ')
+ self.complete_from_to("watchpoint set variable foo --", ["--watch", "--size"])
+ self.complete_from_to("watchpoint set variable foo --w", "watchpoint set variable foo --watch")
+ self.complete_from_to('watchpoint set variable foo -w ', ['read', 'write', 'read_write'])
+ self.complete_from_to("watchpoint set variable foo --watch ", ["read", "write", "read_write"])
+ self.complete_from_to("watchpoint set variable foo --watch w", "watchpoint set variable foo --watch write")
+ self.complete_from_to('watchpoint set variable foo -w read_', 'watchpoint set variable foo -w read_write')
+
@expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")
def test_symbol_name(self):
self.build()
OpenPOWER on IntegriCloud