]> granicus.if.org Git - llvm/commitdiff
Fix fs::set_current_path unit test
authorPavel Labath <labath@google.com>
Tue, 24 Jan 2017 11:35:26 +0000 (11:35 +0000)
committerPavel Labath <labath@google.com>
Tue, 24 Jan 2017 11:35:26 +0000 (11:35 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292916 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Support/Path.cpp

index fb61cc7c26e481cbb35ed379522bab4cb76c8768..bd57ba98f31be00b11c00bcfbaa7201754ffcda4 100644 (file)
@@ -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