LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
(const lldb::SBEnvironment &, bool), env, append);
Environment &refEnv = env.ref();
- if (append)
- m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
- else
+ if (append) {
+ for (auto &KV : refEnv)
+ m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+ } else
m_opaque_sp->GetEnvironment() = refEnv;
m_opaque_sp->RegenerateEnvp();
}
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)
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, [])