aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorDmitry Mikulin <dmitry.mikulin@sony.com>2018-03-05 19:34:33 +0000
committerDmitry Mikulin <dmitry.mikulin@sony.com>2018-03-05 19:34:33 +0000
commit430c7ff73297e8a6cb7391debe6b96a6cfa3806e (patch)
tree12bbda72bfb31d28a9fce7501f1b9b5d45a27d36 /llvm/unittests/Support/CommandLineTest.cpp
parent6cc31ca81446b3fc61e02e2c231436978746decd (diff)
downloadllvm-430c7ff73297e8a6cb7391debe6b96a6cfa3806e.zip
llvm-430c7ff73297e8a6cb7391debe6b96a6cfa3806e.tar.gz
llvm-430c7ff73297e8a6cb7391debe6b96a6cfa3806e.tar.bz2
On Windows we need to be able to process response files with Windows-style
path names. Differential Revision: https://reviews.llvm.org/D43988 llvm-svn: 326737
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 36ff4e2..328dfa3 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -10,6 +10,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Config/config.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@@ -631,6 +632,40 @@ TEST(CommandLineTest, ArgumentLimit) {
EXPECT_FALSE(llvm::sys::commandLineFitsWithinSystemLimits("cl", args.data()));
}
+TEST(CommandLineTest, ResponseFileWindows) {
+ if (!Triple(sys::getProcessTriple()).isOSWindows())
+ return;
+
+ static cl::list<std::string>
+ InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
+ StackOption<bool> TopLevelOpt("top-level", cl::init(false));
+
+ // Create response file.
+ int FileDescriptor;
+ SmallString<64> TempPath;
+ std::error_code EC =
+ llvm::sys::fs::createTemporaryFile("resp-", ".txt", FileDescriptor, TempPath);
+ EXPECT_TRUE(!EC);
+
+ std::ofstream RspFile(TempPath.c_str());
+ EXPECT_TRUE(RspFile.is_open());
+ RspFile << "-top-level\npath\\dir\\file1\npath/dir/file2";
+ RspFile.close();
+
+ llvm::SmallString<128> RspOpt;
+ RspOpt.append(1, '@');
+ RspOpt.append(TempPath.c_str());
+ const char *args[] = {"prog", RspOpt.c_str()};
+ EXPECT_FALSE(TopLevelOpt);
+ EXPECT_TRUE(
+ cl::ParseCommandLineOptions(2, args, StringRef(), &llvm::nulls()));
+ EXPECT_TRUE(TopLevelOpt);
+ EXPECT_TRUE(InputFilenames[0] == "path\\dir\\file1");
+ EXPECT_TRUE(InputFilenames[1] == "path/dir/file2");
+
+ llvm::sys::fs::remove(TempPath.c_str());
+}
+
TEST(CommandLineTest, ResponseFiles) {
llvm::SmallString<128> TestDir;
std::error_code EC =