From f0955922a258aa6d59379b254df2d1b4ab9676af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Thu, 7 Oct 2021 11:31:32 +0000 Subject: [PATCH] [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 --- llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp | 40 ++++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp index d40bf64..82aaa45 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 -- 2.7.4