aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2020-07-06 16:44:37 +0200
committerPavel Labath <pavel@labath.sk>2020-07-08 13:35:31 +0200
commit695b33a56919af8873eecb47cb83fa17a271e99f (patch)
tree0e6a268571229d8074d08b8c00c335eec9eb6ba3 /lldb/test/API/python_api
parentb19913188d03d59332908f6280af37325bc49492 (diff)
downloadllvm-695b33a56919af8873eecb47cb83fa17a271e99f.zip
llvm-695b33a56919af8873eecb47cb83fa17a271e99f.tar.gz
llvm-695b33a56919af8873eecb47cb83fa17a271e99f.tar.bz2
[lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)
Summary: This function was documented to overwrite entries with D76111, which was adding a couple of similar functions. However, this function (unlike the functions added in that patch) was/is not actually overwriting variables -- any pre-existing variables would get ignored. This behavior does not seem to be intentional. In fact, before the refactor in D41359, this function could introduce duplicate entries, which could have very surprising effects both inside lldb and on other applications (some applications would take the first value, some the second one; in lldb, attempting to unset a variable could make the second variable become active, etc.). Overwriting seems to be the most reasonable behavior here, so change the code to match documentation. Reviewers: clayborg, wallace, jingham Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D83306
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
index c1937f9..6389854 100644
--- a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,6 +53,11 @@ class SBEnvironmentAPICase(TestBase):
launch_info.SetEnvironment(env, append=True)
self.assertEqual(launch_info.GetEnvironment().GetNumValues(), env_count + 1)
+ env.Set("FOO", "baz", overwrite=True)
+ launch_info.SetEnvironment(env, append=True)
+ self.assertEqual(launch_info.GetEnvironment().GetNumValues(), env_count + 1)
+ self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
+
# Make sure we can replace the launchInfo's environment
env.Clear()
env.Set("BAR", "foo", overwrite=True)
@@ -120,6 +125,11 @@ class SBEnvironmentAPICase(TestBase):
env.SetEntries(entries, append=False)
self.assertEqualEntries(env, ["X=x", "Y=y"])
+ entries.Clear()
+ entries.AppendList(["X=y", "Y=x"], 2)
+ env.SetEntries(entries, append=True)
+ self.assertEqualEntries(env, ["X=y", "Y=x"])
+
# Test clear
env.Clear()
self.assertEqualEntries(env, [])