[llvm] r292916 - Fix fs::set_current_path unit test

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 03:35:26 PST 2017


Author: labath
Date: Tue Jan 24 05:35:26 2017
New Revision: 292916

URL: http://llvm.org/viewvc/llvm-project?rev=292916&view=rev
Log:
Fix fs::set_current_path unit test

The test fails when there is a symlink on the path because then the path
returned by current_path will not match the one we have set. Instead of
doing a string match check the unique id of the two files.

Modified:
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=292916&r1=292915&r2=292916&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Tue Jan 24 05:35:26 2017
@@ -1151,7 +1151,11 @@ TEST_F(FileSystemTest, set_current_path)
   ASSERT_NO_ERROR(fs::set_current_path(TestDirectory));
 
   ASSERT_NO_ERROR(fs::current_path(path));
-  ASSERT_EQ(TestDirectory, path);
+
+  fs::UniqueID D1, D2;
+  ASSERT_NO_ERROR(fs::getUniqueID(TestDirectory, D1));
+  ASSERT_NO_ERROR(fs::getUniqueID(path, D2));
+  ASSERT_EQ(D1, D2) << "D1: " << TestDirectory << "\nD2: " << path;
 }
 
 } // anonymous namespace




More information about the llvm-commits mailing list