Skip to content

Commit 08acc72

Browse files
committed
Fix the following CAS-related tests with LLVM_ENABLE_ONDISK_CAS=OFF on Windows (#11140)
Clang :: ClangScanDeps/modules-include-tree-pch-common-stale.c Clang :: Driver/fdepscan-prefix-map-sdk.c Clang :: Driver/fdepscan-prefix-map-toolchain.c Clang :: Driver/fdepscan-prefix-map.c Clang-Unit :: ./AllClangUnitTests.exe/DependencyScanningCASFilesystem/DirectiveScanFailure Clang-Unit :: ./AllClangUnitTests.exe/DependencyScanningCASFilesystem/FilenameSpelling Clang-Unit :: ./AllClangUnitTests.exe/IncludeTree/IncludeTreeFileSystemOverlay Clang-Unit :: ./AllClangUnitTests.exe/IncludeTree/IncludeTreeScan LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/BasicRealFSIteration LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/BasicRealFSRecursiveIteration LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/BasicRealFSRecursiveIterationNoPush LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/BrokenSymlinkRealFSIteration LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/BrokenSymlinkRealFSRecursiveIteration LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/ExcludeFromTacking LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/Exists LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/MultipleWorkingDirs LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/TrackNewAccesses LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/TrackNewAccessesExists LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/TrackNewAccessesStack LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/caseSensitivityDir LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/caseSensitivityFile LLVM-Unit :: CAS/./CASTests.exe/CachingOnDiskFileSystemTest/getRealPath LLVM-Unit :: CAS/./CASTests.exe/OnDiskCASLoggerTest/MultiProcess LLVM-Unit :: CAS/./CASTests.exe/OnDiskCASLoggerTest/MultiThread LLVM-Unit :: Support/./SupportTests.exe/OnDiskBackendTest/OnlyIfDifferent LLVM-Unit :: Support/./SupportTests.exe/SourceMgrTest/AddIncludedFile LLVM-Unit :: Support/./SupportTests.exe/TreePathPrefixMapperTest/map LLVM-Unit :: Support/./SupportTests.exe/TreePathPrefixMapperTest/mapInPlace LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/Keep/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/Keep/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepEmpty/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepEmpty/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepFlush/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepFlush/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepFlushProxy/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepFlushProxy/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectory/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectory/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectory/OnDisk_DisableTemporaries LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNested/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNested/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNested/OnDisk_DisableTemporaries LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNoImply/OnDisk LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNoImply/OnDisk_DisableRemoveOnSignal LLVM-Unit :: Support/./SupportTests.exe/VirtualOutput/BackendTest/KeepMissingDirectoryNoImply/OnDisk_DisableTemporaries (cherry picked from commit 506713c)
1 parent e51a289 commit 08acc72

25 files changed

+348
-142
lines changed

clang/test/ClangScanDeps/modules-include-tree-pch-common-stale.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: ondisk_cas
2+
13
// Test that modifications to a common header (imported from both a PCH and a TU)
24
// cause rebuilds of dependent modules imported from the TU on incremental build.
35

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: system-windows
2+
3+
// RUN: %clang -fdepscan-prefix-map-sdk=\^sdk -### %s 2>&1 | FileCheck %s -check-prefix=NONE
4+
// RUN: %clang -fdepscan-prefix-map-sdk=\^sdk -isysroot relative -### %s 2>&1 | FileCheck %s -check-prefix=NONE
5+
6+
// NONE-NOT: -fdepscan-prefix-map
7+
8+
// RUN: %clang -fdepscan-prefix-map-sdk=\^sdk -isysroot C:\sys\path -### %s 2>&1 | FileCheck %s
9+
// RUN: %clang -fdepscan-prefix-map-sdk=\^sdk --sysroot C:\sys\path -### %s 2>&1 | FileCheck %s
10+
// CHECK: "-fdepscan-prefix-map" "C:\\sys\\path" "\\^sdk"

clang/test/Driver/fdepscan-prefix-map-sdk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: !system-windows
2+
13
// RUN: %clang -fdepscan-prefix-map-sdk=/^sdk -### %s 2>&1 | FileCheck %s -check-prefix=NONE
24
// RUN: %clang -fdepscan-prefix-map-sdk=/^sdk -isysroot relative -### %s 2>&1 | FileCheck %s -check-prefix=NONE
35

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: system-windows
2+
3+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir '' -### %s 2>&1 | FileCheck %s -check-prefix=NONE
4+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir relative -### %s 2>&1 | FileCheck %s -check-prefix=NONE
5+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir C:\lib\clang\10 -### %s 2>&1 | FileCheck %s -check-prefix=NONE
6+
7+
// NONE-NOT: -fdepscan-prefix-map
8+
9+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir C:\tc\10 -### %s 2>&1 | FileCheck %s
10+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir C:\tc\lib\clang\10 -### %s 2>&1 | FileCheck %s
11+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -resource-dir C:\tc\usr\lib\clang\10 -### %s 2>&1 | FileCheck %s
12+
13+
// CHECK: "-fdepscan-prefix-map" "C:\\tc" "\\^tc"
14+
15+
// Implicit resource-dir
16+
// RUN: %clang -fdepscan-prefix-map-toolchain=\^tc -### %s 2>&1 | FileCheck %s -check-prefix=CHECK_IMPLICIT
17+
// CHECK_IMPLICIT: "-fdepscan-prefix-map" "{{.*}}" "\\^tc"

clang/test/Driver/fdepscan-prefix-map-toolchain.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: !system-windows
2+
13
// RUN: %clang -fdepscan-prefix-map-toolchain=/^tc -resource-dir '' -### %s 2>&1 | FileCheck %s -check-prefix=NONE
24
// RUN: %clang -fdepscan-prefix-map-toolchain=/^tc -resource-dir relative -### %s 2>&1 | FileCheck %s -check-prefix=NONE
35
// RUN: %clang -fdepscan-prefix-map-toolchain=/^tc -resource-dir /lib/clang/10 -### %s 2>&1 | FileCheck %s -check-prefix=NONE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: system-windows
2+
3+
// RUN: not %clang -fdepscan-prefix-map=\^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
4+
// RUN: not %clang -fdepscan-prefix-map==\^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
5+
// RUN: not %clang -fdepscan-prefix-map=relative=\^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
6+
// RUN: not %clang -fdepscan-prefix-map=\=\^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
7+
// INVALID: error: invalid argument '{{.*}}\^bad' to -fdepscan-prefix-map=
8+
9+
// RUN: %clang -fdepscan-prefix-map=C:\good=\^good -### %s 2>&1 | FileCheck --check-prefix CHECK_CORRECT %s
10+
// CHECK_CORRECT: "-fdepscan-prefix-map" "C:\\good" "\\^good"
11+
12+
// RUN %clang -fdepscan-prefix-map=C:\a=\^a -fdepscan-prefix-map C:\b \^b -fdepscan-prefix-map=C:\c=\^c -fdepscan-prefix-map C:\d \^d -### %s 2>&1 | FileCheck --check-prefix=CHECK_MIXED %s
13+
// CHECK_MIXED: "-fdepscan-prefix-map" "C:\\a" "\\^a" "-fdepscan-prefix-map" "C:\\b" "\\^b" "-fdepscan-prefix-map" "C:\\c" "\\^c" "-fdepscan-prefix-map" "C:\\d" "\\^d"

clang/test/Driver/fdepscan-prefix-map.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// REQUIRES: !system-windows
2+
13
// RUN: not %clang -fdepscan-prefix-map=/^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
24
// RUN: not %clang -fdepscan-prefix-map==/^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID
35
// RUN: not %clang -fdepscan-prefix-map=relative=/^bad -### %s 2>&1 | FileCheck %s -check-prefix=INVALID

clang/unittests/CAS/IncludeTreeTest.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ using namespace tooling;
1717
using namespace dependencies;
1818

1919
TEST(IncludeTree, IncludeTreeScan) {
20+
StringRef PathSep = llvm::sys::path::get_separator();
2021
std::shared_ptr<ObjectStore> DB = llvm::cas::createInMemoryCAS();
2122
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
2223
FS->setCurrentWorkingDirectory("/root");
@@ -109,7 +110,7 @@ TEST(IncludeTree, IncludeTreeScan) {
109110
EXPECT_EQ(A1->getFileCharacteristic(), SrcMgr::C_User);
110111
IncludeTree::FileInfo FI;
111112
ASSERT_THAT_ERROR(A1File->getFileInfo().moveInto(FI), llvm::Succeeded());
112-
EXPECT_EQ(FI.Filename, "./a1.h");
113+
EXPECT_EQ(FI.Filename, "." + PathSep.str() + "a1.h");
113114
EXPECT_EQ(FI.Contents, A1Contents);
114115
EXPECT_FALSE(A1->getCheckResult(0));
115116
EXPECT_TRUE(A1->getCheckResult(1));
@@ -123,7 +124,7 @@ TEST(IncludeTree, IncludeTreeScan) {
123124
EXPECT_EQ(B1->getFileCharacteristic(), SrcMgr::C_User);
124125
IncludeTree::FileInfo FI;
125126
ASSERT_THAT_ERROR(B1->getBaseFileInfo().moveInto(FI), llvm::Succeeded());
126-
EXPECT_EQ(FI.Filename, "./b1.h");
127+
EXPECT_EQ(FI.Filename, "." + PathSep.str() + "b1.h");
127128
EXPECT_EQ(FI.Contents, "");
128129

129130
ASSERT_EQ(B1->getNumIncludes(), uint32_t(0));
@@ -138,7 +139,7 @@ TEST(IncludeTree, IncludeTreeScan) {
138139
EXPECT_EQ(Sys->getFileCharacteristic(), SrcMgr::C_System);
139140
IncludeTree::FileInfo FI;
140141
ASSERT_THAT_ERROR(Sys->getBaseFileInfo().moveInto(FI), llvm::Succeeded());
141-
EXPECT_EQ(FI.Filename, "sys/sys.h");
142+
EXPECT_EQ(FI.Filename, "sys" + PathSep.str() + "sys.h");
142143
EXPECT_EQ(FI.Contents, "");
143144

144145
ASSERT_EQ(Sys->getNumIncludes(), uint32_t(0));
@@ -298,6 +299,7 @@ TEST(IncludeTree, IncludeTreeFileListDuplicates) {
298299
}
299300

300301
TEST(IncludeTree, IncludeTreeFileSystemOverlay) {
302+
StringRef PathSep = llvm::sys::path::get_separator();
301303
std::shared_ptr<ObjectStore> DB = llvm::cas::createInMemoryCAS();
302304
SmallVector<IncludeTree::FileList::FileEntry> Files;
303305
for (unsigned I = 0; I < 10; ++I) {
@@ -328,11 +330,12 @@ TEST(IncludeTree, IncludeTreeFileSystemOverlay) {
328330

329331
std::error_code EC;
330332
int NumFile = 0;
331-
for (auto I = OverlayFS.dir_begin("/dir", EC);
333+
for (auto I = OverlayFS.dir_begin(PathSep.str() + "dir", EC);
332334
!EC && I != llvm::vfs::directory_iterator(); I.increment(EC)) {
333335
ASSERT_FALSE(EC);
334336
++NumFile;
335-
std::string Path = "/dir/file" + std::to_string(NumFile);
337+
std::string Path = PathSep.str() + "dir" + PathSep.str() + "file" +
338+
std::to_string(NumFile);
336339
ASSERT_EQ(I->path(), Path);
337340
}
338341
ASSERT_EQ(NumFile, 2);

clang/unittests/Tooling/DependencyScanningCASFilesystemTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ using llvm::unittest::TempLink;
2424
TEST(DependencyScanningCASFilesystem, FilenameSpelling) {
2525
TempDir TestDir("DependencyScanningCASFilesystemTest", /*Unique=*/true);
2626
TempFile TestFile(TestDir.path("File.h"), "", "#define FOO\n");
27+
#ifndef _WIN32
2728
TempLink TestLink("File.h", TestDir.path("SymFile.h"));
29+
#else
30+
// As the create_link uses a hard link on Windows, the full path is
31+
// required for the link target.
32+
TempLink TestLink(TestDir.path("File.h"), TestDir.path("SymFile.h"));
33+
#endif
2834

2935
std::unique_ptr<ObjectStore> CAS = llvm::cas::createInMemoryCAS();
3036
std::unique_ptr<ActionCache> Cache = llvm::cas::createInMemoryActionCache();

llvm/include/llvm/CAS/CASFileSystem.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ namespace cas {
1717
class ObjectStore;
1818
class CASID;
1919

20-
// FIXME: Consider taking a "mount point". Then this could perhaps be
21-
// generalized for windows.
2220
Expected<std::unique_ptr<vfs::FileSystem>>
23-
createCASFileSystem(std::shared_ptr<ObjectStore> DB, const CASID &RootID);
21+
createCASFileSystem(std::shared_ptr<ObjectStore> DB, const CASID &RootID,
22+
sys::path::Style PathStyle = sys::path::Style::native);
2423

25-
// FIXME: Consider taking a "mount point". Then this could perhaps be
26-
// generalized for windows.
2724
Expected<std::unique_ptr<vfs::FileSystem>>
28-
createCASFileSystem(ObjectStore &DB, const CASID &RootID);
25+
createCASFileSystem(ObjectStore &DB, const CASID &RootID,
26+
sys::path::Style PathStyle = sys::path::Style::native);
2927

3028
} // namespace cas
3129
} // namespace llvm

0 commit comments

Comments
 (0)