[llvm] f095592 - [unittests] [DWARF] Generalize path separator expectations

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 5 12:51:10 PDT 2021


Author: Martin Storsjö
Date: 2021-11-05T21:50:43+02:00
New Revision: f0955922a258aa6d59379b254df2d1b4ab9676af

URL: https://github.com/llvm/llvm-project/commit/f0955922a258aa6d59379b254df2d1b4ab9676af
DIFF: https://github.com/llvm/llvm-project/commit/f0955922a258aa6d59379b254df2d1b4ab9676af.diff

LOG: [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

Added: 
    

Modified: 
    llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
index d40bf6445f40d..82aaa458515a5 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
@@ -183,11 +183,9 @@ TEST(DWARFDie, getDeclFile) {
   std::string DeclFile = MainDie.getDeclFile(
       DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
 
-#if defined(_WIN32)
-  EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
-#else
-  EXPECT_EQ(DeclFile, "/tmp/main.cpp");
-#endif
+  std::string Ref =
+      ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
+  EXPECT_EQ(DeclFile, Ref);
 }
 
 TEST(DWARFDie, getDeclFileAbstractOrigin) {
@@ -291,11 +289,9 @@ TEST(DWARFDie, getDeclFileAbstractOrigin) {
   std::string DeclFile = MainDie.getDeclFile(
       DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
 
-#if defined(_WIN32)
-  EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
-#else
-  EXPECT_EQ(DeclFile, "/tmp/main.cpp");
-#endif
+  std::string Ref =
+      ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
+  EXPECT_EQ(DeclFile, Ref);
 }
 
 TEST(DWARFDie, getDeclFileSpecification) {
@@ -398,11 +394,9 @@ TEST(DWARFDie, getDeclFileSpecification) {
   std::string DeclFile = MainDie.getDeclFile(
       DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
 
-#if defined(_WIN32)
-  EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
-#else
-  EXPECT_EQ(DeclFile, "/tmp/main.cpp");
-#endif
+  std::string Ref =
+      ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
+  EXPECT_EQ(DeclFile, Ref);
 }
 
 TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) {
@@ -522,11 +516,9 @@ TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) {
   std::string DeclFile = MainDie.getDeclFile(
       DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
 
-#if defined(_WIN32)
-  EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
-#else
-  EXPECT_EQ(DeclFile, "/tmp/main.cpp");
-#endif
+  std::string Ref =
+      ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
+  EXPECT_EQ(DeclFile, Ref);
 }
 
 TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) {
@@ -646,11 +638,9 @@ TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) {
   std::string DeclFile = MainDie.getDeclFile(
       DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
 
-#if defined(_WIN32)
-  EXPECT_EQ(DeclFile, "/tmp\\main.cpp");
-#else
-  EXPECT_EQ(DeclFile, "/tmp/main.cpp");
-#endif
+  std::string Ref =
+      ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str();
+  EXPECT_EQ(DeclFile, Ref);
 }
 
 } // end anonymous namespace


        


More information about the llvm-commits mailing list