@@ -51,6 +51,11 @@ class DummyFileSystem : public vfs::FileSystem {
51
51
FilesAndDirs.find (Path.str ());
52
52
if (I == FilesAndDirs.end ())
53
53
return make_error_code (llvm::errc::no_such_file_or_directory);
54
+ // Simulate a broken symlink, where it points to a file/dir that
55
+ // does not exist.
56
+ if (I->second .isSymlink () &&
57
+ I->second .getPermissions () == sys::fs::perms::no_perms)
58
+ return std::error_code (ENOENT, std::generic_category ());
54
59
return I->second ;
55
60
}
56
61
ErrorOr<std::unique_ptr<vfs::File>>
@@ -152,6 +157,13 @@ class DummyFileSystem : public vfs::FileSystem {
152
157
sys::fs::file_type::symlink_file, sys::fs::all_all);
153
158
addEntry (Path, S);
154
159
}
160
+
161
+ void addBrokenSymlink (StringRef Path) {
162
+ vfs::Status S (Path, UniqueID (FSID, FileID++),
163
+ std::chrono::system_clock::now (), 0 , 0 , 0 ,
164
+ sys::fs::file_type::symlink_file, sys::fs::no_perms);
165
+ addEntry (Path, S);
166
+ }
155
167
};
156
168
} // namespace
157
169
@@ -178,6 +190,7 @@ static IntrusiveRefCntPtr<DummyFileSystem> GetSimpleDummyFS() {
178
190
D->addRegularFile (" /foo" );
179
191
D->addDirectory (" /bar" );
180
192
D->addSymlink (" /baz" );
193
+ D->addBrokenSymlink (" /lux" );
181
194
D->addRegularFile (" /qux" , ~sys::fs::perms::all_read);
182
195
D->setCurrentWorkingDirectory (" /" );
183
196
return D;
0 commit comments