diff options
| author | Dave Lee <davelee.com@gmail.com> | 2018-07-04 16:11:43 +0000 |
|---|---|---|
| committer | Dave Lee <davelee.com@gmail.com> | 2018-07-04 16:11:43 +0000 |
| commit | 8ab5c2db8a7345143fc994718303fda2a63f90c3 (patch) | |
| tree | 2b6e3a230d1890e63b9bb049a773854357749a75 /lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py | |
| parent | 17c0c4e7424187c50c3189566aa3432cee7cdc9a (diff) | |
| download | bcm5719-llvm-8ab5c2db8a7345143fc994718303fda2a63f90c3.tar.gz bcm5719-llvm-8ab5c2db8a7345143fc994718303fda2a63f90c3.zip | |
Fix and simplify lldb.command decorator
Summary:
This change fixes one issue with `lldb.command`, and also reduces the implementation.
The fix: a command function's docstring was not shown when running `help <command_name>`. This is because the docstring attached the source function is not propagated to the decorated function (`f.__call__`). By returning the original function, the docstring will be properly displayed by `help`.
Also with this change, the command name is assumed to be the function's name, but can still be explicitly defined as previously.
Additionally, the implementation was updated to:
* Remove inner class
* Remove use of `inspect` module
* Remove `*args` and `**kwargs`
Reviewers: clayborg
Reviewed By: clayborg
Subscribers: keith, xiaobai, lldb-commits
Differential Revision: https://reviews.llvm.org/D48658
llvm-svn: 336287
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py')
| -rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py index 103189e9dd5..1698c0d0c35 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py @@ -49,6 +49,7 @@ class CmdPythonTestCase(TestBase): self.runCmd('command script delete tell_curr', check=False) self.runCmd('command script delete bug11569', check=False) self.runCmd('command script delete takes_exe_ctx', check=False) + self.runCmd('command script delete decorated', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -67,13 +68,19 @@ class CmdPythonTestCase(TestBase): substrs=['Just a docstring for welcome_impl', 'A command that says hello to LLDB users']) + decorated_commands = ["decorated" + str(n) for n in range(1, 5)] + for name in decorated_commands: + self.expect(name, substrs=["hello from " + name]) + self.expect("help " + name, + substrs=["Python command defined by @lldb.command"]) + self.expect("help", substrs=['For more information run', - 'welcome']) + 'welcome'] + decorated_commands) self.expect("help -a", substrs=['For more information run', - 'welcome']) + 'welcome'] + decorated_commands) self.expect("help -u", matching=False, substrs=['For more information run']) |

