[Lldb-commits] [lldb] r369524 - [lldb] Add tests for 'settings remove' and fix error message typos
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 21 06:24:21 PDT 2019
Author: teemperor
Date: Wed Aug 21 06:24:21 2019
New Revision: 369524
URL: http://llvm.org/viewvc/llvm-project?rev=369524&view=rev
Log:
[lldb] Add tests for 'settings remove' and fix error message typos
Modified:
lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
lldb/trunk/source/Commands/CommandObjectSettings.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py?rev=369524&r1=369523&r2=369524&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py Wed Aug 21 06:24:21 2019
@@ -481,6 +481,45 @@ class SettingsCommandTestCase(TestBase):
substrs=['disassembly-format (format-string) = "foo "'])
self.runCmd("settings clear disassembly-format", check=False)
+ def test_settings_list(self):
+ # List settings (and optionally test the filter to only show 'target' settings).
+ self.expect("settings list target", substrs=["language", "arg0", "detach-on-error"])
+ self.expect("settings list target", matching=False, substrs=["packet-timeout"])
+ self.expect("settings list", substrs=["language", "arg0", "detach-on-error", "packet-timeout"])
+
+ def test_settings_remove_single(self):
+ # Set some environment variables and use 'remove' to delete them.
+ self.runCmd("settings set target.env-vars a=b c=d")
+ self.expect("settings show target.env-vars", substrs=["a=b", "c=d"])
+ self.runCmd("settings remove target.env-vars a")
+ self.expect("settings show target.env-vars", matching=False, substrs=["a=b"])
+ self.expect("settings show target.env-vars", substrs=["c=d"])
+ self.runCmd("settings remove target.env-vars c")
+ self.expect("settings show target.env-vars", matching=False, substrs=["a=b", "c=d"])
+
+ def test_settings_remove_multiple(self):
+ self.runCmd("settings set target.env-vars a=b c=d e=f")
+ self.expect("settings show target.env-vars", substrs=["a=b", "c=d", "e=f"])
+ self.runCmd("settings remove target.env-vars a e")
+ self.expect("settings show target.env-vars", matching=False, substrs=["a=b", "e=f"])
+ self.expect("settings show target.env-vars", substrs=["c=d"])
+
+ def test_settings_remove_nonexistent_value(self):
+ self.expect("settings remove target.env-vars doesntexist", error=True,
+ substrs=["no value found named 'doesntexist'"])
+
+ def test_settings_remove_nonexistent_settings(self):
+ self.expect("settings remove doesntexist alsodoesntexist", error=True,
+ substrs=["error: invalid value path 'doesntexist'"])
+
+ def test_settings_remove_missing_arg(self):
+ self.expect("settings remove", error=True,
+ substrs=["'settings remove' takes an array or dictionary item, or"])
+
+ def test_settings_remove_empty_arg(self):
+ self.expect("settings remove ''", error=True,
+ substrs=["'settings remove' command requires a valid variable name"])
+
def test_all_settings_exist(self):
self.expect("settings show",
substrs=["auto-confirm",
Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=369524&r1=369523&r2=369524&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Aug 21 06:24:21 2019
@@ -638,8 +638,8 @@ protected:
const size_t argc = cmd_args.GetArgumentCount();
if (argc == 0) {
- result.AppendError("'settings set' takes an array or dictionary item, or "
- "an array followed by one or more indexes, or a "
+ result.AppendError("'settings remove' takes an array or dictionary item, "
+ "or an array followed by one or more indexes, or a "
"dictionary followed by one or more key names to "
"remove");
result.SetStatus(eReturnStatusFailed);
@@ -649,7 +649,7 @@ protected:
const char *var_name = cmd_args.GetArgumentAtIndex(0);
if ((var_name == nullptr) || (var_name[0] == '\0')) {
result.AppendError(
- "'settings set' command requires a valid variable name");
+ "'settings remove' command requires a valid variable name");
result.SetStatus(eReturnStatusFailed);
return false;
}
More information about the lldb-commits
mailing list