[PATCH] D60630: [Support] Add a test for recursive response file expansion
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 12:54:11 PDT 2019
smeenai created this revision.
smeenai added reviewers: rnk, hans.
Herald added a project: LLVM.
I'm going to be modifying the logic to avoid infinitely recursing on
self-referential response files, so add a unit test to verify the
expected behavior.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60630
Files:
llvm/unittests/Support/CommandLineTest.cpp
Index: llvm/unittests/Support/CommandLineTest.cpp
===================================================================
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -720,6 +720,37 @@
llvm::sys::fs::remove(TestDir);
}
+TEST(CommandLineTest, RecursiveResponseFiles) {
+ SmallString<128> TestDir;
+ std::error_code EC = sys::fs::createUniqueDirectory("unittest", TestDir);
+ EXPECT_TRUE(!EC);
+
+ SmallString<128> ResponseFilePath;
+ sys::path::append(ResponseFilePath, TestDir, "recursive.rsp");
+ std::string ResponseFileRef = std::string("@") + ResponseFilePath.c_str();
+
+ std::ofstream ResponseFile(ResponseFilePath.c_str());
+ EXPECT_TRUE(ResponseFile.is_open());
+ ResponseFile << ResponseFileRef << "\n";
+ ResponseFile << ResponseFileRef << "\n";
+ ResponseFile.close();
+
+ // Ensure the recursive expansion terminates.
+ llvm::SmallVector<const char *, 4> Argv = {"test/test",
+ ResponseFileRef.c_str()};
+ llvm::BumpPtrAllocator A;
+ llvm::StringSaver Saver(A);
+ bool Res = llvm::cl::ExpandResponseFiles(
+ Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, false);
+ EXPECT_FALSE(Res);
+
+ // Ensure some expansion took place.
+ EXPECT_GT(Argv.size(), 2U);
+ EXPECT_STREQ(Argv[0], "test/test");
+ for (size_t i = 1; i < Argv.size(); ++i)
+ EXPECT_STREQ(Argv[i], ResponseFileRef.c_str());
+}
+
TEST(CommandLineTest, SetDefautValue) {
cl::ResetCommandLineParser();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60630.194942.patch
Type: text/x-patch
Size: 1513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190412/1577a889/attachment-0001.bin>
More information about the llvm-commits
mailing list