aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-09-25 21:07:20 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-09-25 21:07:20 +0000
commit14a5cc54e58316fd514e6f6865575b65d8d088c3 (patch)
treebf923ac5b1556630b96aefd18797aff6840c21bf /llvm/unittests/Support/CommandLineTest.cpp
parentf6a987b784800c04add49b0b50d8d383f8ed4c0b (diff)
downloadllvm-14a5cc54e58316fd514e6f6865575b65d8d088c3.zip
llvm-14a5cc54e58316fd514e6f6865575b65d8d088c3.tar.gz
llvm-14a5cc54e58316fd514e6f6865575b65d8d088c3.tar.bz2
Fix a compile failure introduced by r82675 on MinGW which doesn't have
setenv(). This patch just disables the test rather than getting putenv() to work. Thanks to Sandeep Patel for reporting the problem. llvm-svn: 82797
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 70d6950..72fa24a 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
+#include "llvm/Config/config.h"
#include "gtest/gtest.h"
@@ -24,17 +25,26 @@ class TempEnvVar {
: name(name) {
const char *old_value = getenv(name);
EXPECT_EQ(NULL, old_value) << old_value;
+#if HAVE_SETENV
setenv(name, value, true);
+#else
+# define SKIP_ENVIRONMENT_TESTS
+#endif
}
~TempEnvVar() {
+#if HAVE_SETENV
+ // Assume setenv and unsetenv come together.
unsetenv(name);
+#endif
}
private:
const char *const name;
};
+#ifndef SKIP_ENVIRONMENT_TESTS
+
const char test_env_var[] = "LLVM_TEST_COMMAND_LINE_FLAGS";
cl::opt<std::string> EnvironmentTestOption("env-test-opt");
@@ -45,4 +55,6 @@ TEST(CommandLineTest, ParseEnvironment) {
EXPECT_EQ("hello", EnvironmentTestOption);
}
+#endif // SKIP_ENVIRONMENT_TESTS
+
} // anonymous namespace