Skip to content

Commit f095592

Browse files
committed
[unittests] [DWARF] Generalize path separator expectations
This fixes unit tests if running on Windows with a build configured to prefer forward slashes. Differential Revision: https://reviews.llvm.org/D113257
1 parent 86c01b1 commit f095592

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ TEST(DWARFDie, getDeclFile) {
183183
std::string DeclFile = MainDie.getDeclFile(
184184
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
185185

186-
#if defined(_WIN32)
187-
EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
188-
#else
189-
EXPECT_EQ(DeclFile, "/tmp/main.cpp");
190-
#endif
186+
std::string Ref =
187+
("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
188+
EXPECT_EQ(DeclFile, Ref);
191189
}
192190

193191
TEST(DWARFDie, getDeclFileAbstractOrigin) {
@@ -291,11 +289,9 @@ TEST(DWARFDie, getDeclFileAbstractOrigin) {
291289
std::string DeclFile = MainDie.getDeclFile(
292290
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
293291

294-
#if defined(_WIN32)
295-
EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
296-
#else
297-
EXPECT_EQ(DeclFile, "/tmp/main.cpp");
298-
#endif
292+
std::string Ref =
293+
("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
294+
EXPECT_EQ(DeclFile, Ref);
299295
}
300296

301297
TEST(DWARFDie, getDeclFileSpecification) {
@@ -398,11 +394,9 @@ TEST(DWARFDie, getDeclFileSpecification) {
398394
std::string DeclFile = MainDie.getDeclFile(
399395
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
400396

401-
#if defined(_WIN32)
402-
EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
403-
#else
404-
EXPECT_EQ(DeclFile, "/tmp/main.cpp");
405-
#endif
397+
std::string Ref =
398+
("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
399+
EXPECT_EQ(DeclFile, Ref);
406400
}
407401

408402
TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) {
@@ -522,11 +516,9 @@ TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) {
522516
std::string DeclFile = MainDie.getDeclFile(
523517
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
524518

525-
#if defined(_WIN32)
526-
EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
527-
#else
528-
EXPECT_EQ(DeclFile, "/tmp/main.cpp");
529-
#endif
519+
std::string Ref =
520+
("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
521+
EXPECT_EQ(DeclFile, Ref);
530522
}
531523

532524
TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) {
@@ -646,11 +638,9 @@ TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) {
646638
std::string DeclFile = MainDie.getDeclFile(
647639
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
648640

649-
#if defined(_WIN32)
650-
EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
651-
#else
652-
EXPECT_EQ(DeclFile, "/tmp/main.cpp");
653-
#endif
641+
std::string Ref =
642+
("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
643+
EXPECT_EQ(DeclFile, Ref);
654644
}
655645

656646
} // end anonymous namespace

0 commit comments

Comments
 (0)