Author: rafael
Date: Wed Jun 26 11:20:55 2013
New Revision: 184959
URL: http://llvm.org/viewvc/llvm-project?rev=184959&view=rev
Log:
Don't use PathV1.h in IncludeExcludeTest.cpp.
Modified:
clang-tools-extra/trunk/unittests/cpp11-migrate/IncludeExcludeTest.cpp
Modified: clang-tools-extra/trunk/unittests/cpp11-migrate/IncludeExcludeTest.cpp
URL:
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/IncludeExcludeTest.cpp?rev=184959&r1=184958&r2=184959&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/IncludeExcludeTest.cpp
(original)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/IncludeExcludeTest.cpp Wed
Jun 26 11:20:55 2013
@@ -1,9 +1,21 @@
#include "Core/IncludeExcludeInfo.h"
#include "gtest/gtest.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/PathV1.h"
#include <fstream>
+// FIXME: copied from unittests/Support/Path.cpp
+#define ASSERT_NO_ERROR(x)
\
+ if (llvm::error_code ASSERT_NO_ERROR_ec = x) {
\
+ llvm::SmallString<128> MessageStorage;
\
+ llvm::raw_svector_ostream Message(MessageStorage);
\
+ Message << #x ": did not return errc::success.\n"
\
+ << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n"
\
+ << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n";
\
+ GTEST_FATAL_FAILURE_(MessageStorage.c_str());
\
+ } else {
\
+ }
+
TEST(IncludeExcludeTest, ParseString) {
IncludeExcludeInfo IEManager;
llvm::error_code Err = IEManager.readListFromString(
@@ -38,29 +50,35 @@ struct InputFiles {
// This function uses fatal assertions. The caller is responsible for making
// sure fatal assertions propagate.
void CreateFiles(bool UnixMode) {
- IncludeDataPath = llvm::sys::Path::GetTemporaryDirectory();
- ExcludeDataPath = IncludeDataPath;
+ llvm::SmallString<128> Path;
+ int FD;
- ASSERT_FALSE(IncludeDataPath.createTemporaryFileOnDisk());
- std::ofstream IncludeDataFile(IncludeDataPath.c_str());
- ASSERT_TRUE(IncludeDataFile.good());
- for (unsigned i = 0; i < sizeof(IncludeData)/sizeof(char*); ++i) {
- IncludeDataFile << IncludeData[i] << (UnixMode ? "\n" : "\r\n");
+ ASSERT_NO_ERROR(
+ llvm::sys::fs::unique_file("include-%%%%%%", FD, Path));
+ IncludeDataPath = Path.str();
+ {
+ llvm::raw_fd_ostream IncludeDataFile(FD, true);
+ for (unsigned i = 0; i < sizeof(IncludeData) / sizeof(char *); ++i) {
+ IncludeDataFile << IncludeData[i] << (UnixMode ? "\n" : "\r\n");
+ }
}
- ASSERT_FALSE(ExcludeDataPath.createTemporaryFileOnDisk());
- std::ofstream ExcludeDataFile(ExcludeDataPath.c_str());
- ASSERT_TRUE(ExcludeDataFile.good());
- for (unsigned i = 0; i < sizeof(ExcludeData)/sizeof(char*); ++i) {
- ExcludeDataFile << ExcludeData[i] << (UnixMode ? "\n" : "\r\n");;
+ ASSERT_NO_ERROR(
+ llvm::sys::fs::unique_file("exclude-%%%%%%", FD, Path));
+ ExcludeDataPath = Path.str();
+ {
+ llvm::raw_fd_ostream ExcludeDataFile(FD, true);
+ for (unsigned i = 0; i < sizeof(ExcludeData) / sizeof(char *); ++i) {
+ ExcludeDataFile << ExcludeData[i] << (UnixMode ? "\n" : "\r\n");
+ }
}
}
static const char *IncludeData[3];
static const char *ExcludeData[4];
- llvm::sys::Path IncludeDataPath;
- llvm::sys::Path ExcludeDataPath;
+ std::string IncludeDataPath;
+ std::string ExcludeDataPath;
};
const char *InputFiles::IncludeData[3] = { "a", "b/b2", "c/c2" };
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits