|
1 | 1 | #include <gtest/gtest.h> |
2 | | -#include <cstdlib> |
3 | 2 |
|
4 | 3 | import std; |
5 | 4 | import mcpp.xlings; |
| 5 | +import mcpp.platform.env; |
6 | 6 |
|
7 | 7 | namespace { |
8 | 8 |
|
@@ -174,9 +174,9 @@ TEST(XlingsSiblingPackage, MetadataOnlyHuskIsNotContent) { |
174 | 174 |
|
175 | 175 | // Isolate from the host's ~/.xlings fallback. |
176 | 176 | const char* oldHome = std::getenv("HOME"); |
177 | | - ::setenv("HOME", tmp.c_str(), 1); |
| 177 | + mcpp::platform::env::set("HOME", tmp.string()); |
178 | 178 | auto found = mcpp::xlings::paths::find_sibling_package(gccBin, "linux-headers"); |
179 | | - if (oldHome) ::setenv("HOME", oldHome, 1); else ::unsetenv("HOME"); |
| 179 | + mcpp::platform::env::set("HOME", oldHome ? oldHome : ""); |
180 | 180 |
|
181 | 181 | EXPECT_FALSE(found.has_value()); |
182 | 182 |
|
@@ -235,10 +235,11 @@ TEST(XlingsHomeTool, FindsPayloadUnderNonXimPrefix) { |
235 | 235 | auto real = xpkgs / "scode-x-linux-headers" / "5.11.1"; |
236 | 236 | touch(real / "include" / "linux" / "limits.h"); |
237 | 237 |
|
238 | | - ::setenv("MCPP_HOME", tmp.c_str(), 1); |
| 238 | + const char* oldMcppHome = std::getenv("MCPP_HOME"); |
| 239 | + mcpp::platform::env::set("MCPP_HOME", tmp.string()); |
239 | 240 | auto found = mcpp::xlings::paths::find_home_tool( |
240 | 241 | "linux-headers", "include/linux/limits.h"); |
241 | | - ::unsetenv("MCPP_HOME"); |
| 242 | + mcpp::platform::env::set("MCPP_HOME", oldMcppHome ? oldMcppHome : ""); |
242 | 243 |
|
243 | 244 | ASSERT_TRUE(found.has_value()); |
244 | 245 | EXPECT_EQ(*found, real); |
|
0 commit comments