Revert D4832473: [Folly] Disable EnvUtil::setAsCurrentEnvironment() on platforms...
authorChristopher Dykes <cdykes@fb.com>
Tue, 11 Apr 2017 02:23:54 +0000 (19:23 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 11 Apr 2017 02:37:22 +0000 (19:37 -0700)
Summary: This reverts commit a80aabb5a223264746ab45e3138d065bce5fe99c

Differential Revision: D4832473

fbshipit-source-id: 1a78d61f3f09f1064876a786c15601a091f4402b

folly/experimental/EnvUtil.cpp
folly/experimental/EnvUtil.h
folly/experimental/test/EnvUtilTest.cpp

index 1035575dc81a0c1542ddff612b38b7d44e250db1..5c16ee7407a53b6d2a80fa8d612190c9b01f0d36 100644 (file)
@@ -44,14 +44,12 @@ EnvironmentState EnvironmentState::fromCurrentEnvironment() {
   return EnvironmentState{std::move(data)};
 }
 
-#if __linux__ && !FOLLY_MOBILE
 void EnvironmentState::setAsCurrentEnvironment() {
   PCHECK(0 == clearenv());
   for (const auto& kvp : env_) {
     PCHECK(0 == setenv(kvp.first.c_str(), kvp.second.c_str(), (int)true));
   }
 }
-#endif
 
 std::vector<std::string> EnvironmentState::toVector() const {
   std::vector<std::string> result;
index 3ab06164fd5b8b1a36fd2dbc566206db31dc1394..3ab3b16af726bf35aa4add3cdcca6da28318cf15 100644 (file)
@@ -64,14 +64,12 @@ struct EnvironmentState {
     return &env_;
   }
 
-#if __linux__ && !FOLLY_MOBILE
   // Update the process environment with the one in the stored model.
   // Subsequent changes to the model do not alter the process environment. The
   // state of the process environment during execution of this method is not
   // defined. If the process environment is altered by another thread during the
   // execution of this method the results are not defined.
   void setAsCurrentEnvironment();
-#endif
 
   // Get a copy of the model environment in the form used by `folly::Subprocess`
   std::vector<std::string> toVector() const;
index 1e1e3d2d8a8096064f25f06fd039f31a843bd399..bcac455da34643277472a2b11fd7afc1c9a66f38 100644 (file)
@@ -132,7 +132,6 @@ TEST(EnvironmentStateTest, Separation) {
   EXPECT_STREQ("foon", getenv("spork"));
 }
 
-#if __linux__ && !FOLLY_MOBILE
 TEST(EnvironmentStateTest, Update) {
   EnvVarSaver saver{};
   auto env = EnvironmentState::fromCurrentEnvironment();
@@ -142,7 +141,6 @@ TEST(EnvironmentStateTest, Update) {
   env.setAsCurrentEnvironment();
   EXPECT_STREQ("foon", getenv("spork"));
 }
-#endif
 
 TEST(EnvironmentStateTest, forSubprocess) {
   auto env = EnvironmentState::empty();