[clang] [clang][deps] Only bypass scanning VFS for the module cache (PR #88800)
Alexandre Ganea via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 09:33:37 PDT 2024
================
@@ -174,3 +174,30 @@ TEST(DependencyScanningFilesystem, CacheStatOnExists) {
EXPECT_EQ(InstrumentingFS->NumStatusCalls, 2u);
EXPECT_EQ(InstrumentingFS->NumExistsCalls, 0u);
}
+
+TEST(DependencyScanningFilesystem, CacheStatFailures) {
+ auto InMemoryFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
+ InMemoryFS->setCurrentWorkingDirectory("/");
+ InMemoryFS->addFile("/dir/vector", 0, llvm::MemoryBuffer::getMemBuffer(""));
+ InMemoryFS->addFile("/cache/a.pcm", 0, llvm::MemoryBuffer::getMemBuffer(""));
+
+ auto InstrumentingFS =
+ llvm::makeIntrusiveRefCnt<InstrumentingFilesystem>(InMemoryFS);
+
+ DependencyScanningFilesystemSharedCache SharedCache;
+ DependencyScanningWorkerFilesystem DepFS(SharedCache, InstrumentingFS);
+
+ DepFS.status("/dir");
+ DepFS.status("/dir");
+ EXPECT_EQ(InstrumentingFS->NumStatusCalls, 1u);
+
+ DepFS.status("/dir/vector");
+ DepFS.status("/dir/vector");
+ EXPECT_EQ(InstrumentingFS->NumStatusCalls, 2u);
+
+ DepFS.setBypassedPathPrefix("/cache");
+ DepFS.exists("/cache/a.pcm");
+ EXPECT_EQ(InstrumentingFS->NumStatusCalls, 3u);
+ DepFS.exists("/cache/a.pcm");
+ EXPECT_EQ(InstrumentingFS->NumStatusCalls, 4u);
----------------
aganea wrote:
Maybe test calling `DepFS.resetBypassedPathPrefix()` also here?
https://github.com/llvm/llvm-project/pull/88800
More information about the cfe-commits
mailing list