replace "leaky" call to putenv() with setenv() on non-windows platforms

This commit is contained in:
Axel Kohlmeyer
2021-04-09 20:37:01 -04:00
parent a69c5a5cae
commit c16e4f241f
2 changed files with 19 additions and 12 deletions

View File

@ -398,30 +398,28 @@ TEST_F(SimpleCommandsTest, Shell)
{
BEGIN_HIDE_OUTPUT();
command("shell putenv TEST_VARIABLE=simpletest");
command("variable simple1 getenv TEST_VARIABLE");
END_HIDE_OUTPUT();
char *test_var = getenv("TEST_VARIABLE");
const char *test_var = getenv("TEST_VARIABLE");
ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest"));
BEGIN_HIDE_OUTPUT();
command("shell putenv TEST_VARIABLE=simpletest2");
command("shell putenv TEST_VARIABLE");
command("shell putenv TEST_VARIABLE2=simpletest OTHER_VARIABLE=2");
END_HIDE_OUTPUT();
char *test_var2 = getenv("TEST_VARIABLE2");
char *other_var = getenv("OTHER_VARIABLE");
test_var = getenv("TEST_VARIABLE2");
ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest"));
ASSERT_NE(test_var2, nullptr);
ASSERT_THAT(test_var2, StrEq("simpletest"));
ASSERT_NE(other_var, nullptr);
ASSERT_THAT(other_var, StrEq("2"));
test_var = getenv("OTHER_VARIABLE");
ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("2"));
test_var = getenv("TEST_VARIABLE");
ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest2"));
ASSERT_THAT(test_var, StrEq(""));
}
TEST_F(SimpleCommandsTest, CiteMe)