Skip to content

Commit ae63caf

Browse files
committed
Fix the following CAS-related tests on Windows (#11320)
Clang :: ClangScanDeps/cas-case-sensitivity.c Clang :: ClangScanDeps/cas-fs-multiple-commands.c Clang :: ClangScanDeps/include-tree-preserve-pch-path.c (Cherry picked from commit 9cf17f4)
1 parent 0cbdb4b commit ae63caf

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

clang/test/ClangScanDeps/cas-case-sensitivity.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
// RUN: sed -e 's/^.*llvmcas/llvmcas/' -e 's/ for.*$//' %t/result1.txt > %t/casid1
1111
// RUN: sed -e 's/^.*llvmcas/llvmcas/' -e 's/ for.*$//' %t/result2.txt > %t/casid2
1212

13-
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid1 | FileCheck -check-prefix=TREE %s -DPREFIX=%/t
14-
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid2 | FileCheck -check-prefix=TREE %s -DPREFIX=%/t
13+
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid1 | FileCheck -check-prefix=TREE %s -DPREFIX=%{t-tree-/}
14+
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid2 | FileCheck -check-prefix=TREE %s -DPREFIX=%{t-tree-/}
1515

1616
// asdf: FileCheck -check-prefix=TREE %s -input-file %t/result1.txt -DPREFIX=%/t
1717

18-
// TREE: file llvmcas://{{.*}} [[PREFIX]]/Header.h
19-
// TREE: syml llvmcas://{{.*}} [[PREFIX]]/header.h -> Header
20-
// TREE: file llvmcas://{{.*}} [[PREFIX]]/t{{[12]}}.c
18+
// TREE: file llvmcas://{{.*}} [[PREFIX]]{{/|\\}}Header.h
19+
// TREE: syml llvmcas://{{.*}} [[PREFIX]]{{/|\\}}header.h -> Header
20+
// TREE: file llvmcas://{{.*}} [[PREFIX]]{{/|\\}}t{{[12]}}.c
2121

2222
//--- cdb1.json.template
2323
[

clang/test/ClangScanDeps/cas-fs-multiple-commands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
// RUN: cat %t/deps.0.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
2121

22-
// RUN: CLANG_CACHE_USE_CASFS_DEPSCAN=1 c-index-test core -scan-deps -working-dir %t -cas-path %t/cas -output-dir %t/modules -- \
22+
// RUN: env CLANG_CACHE_USE_CASFS_DEPSCAN=1 c-index-test core -scan-deps -working-dir %t -cas-path %t/cas -output-dir %t/modules -- \
2323
// RUN: %clang -target x86_64-apple-darwin -c %t/tu.c -save-temps=obj -o %t/tu.o \
2424
// RUN: -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
2525
// RUN: > %t/deps.txt

clang/test/ClangScanDeps/include-tree-preserve-pch-path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// RUN: %deps-to-rsp %t/deps_tu.json --tu-index 0 > %t/tu.rsp
2121
// RUN: %clang @%t/tu.rsp
2222

23-
// RUN: cat %t/tu.ll | FileCheck %s -check-prefix=LLVMIR -DPREFIX=%/t
23+
// RUN: cat %t/tu.ll | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s -check-prefix=LLVMIR
2424
// LLVMIR: !DICompileUnit({{.*}}, splitDebugFilename: "prefix.pch"
2525

2626
// Extract include-tree casid

llvm/lib/CAS/CachingOnDiskFileSystem.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,21 @@ CachingOnDiskFileSystemImpl::makeSymlinkTo(DirectoryEntry &Parent,
361361
TargetStorage.Path);
362362
}
363363

364+
static bool is_executable(StringRef TreePath, sys::fs::file_status Status,
365+
sys::path::Style PathStyle) {
366+
#ifndef _WIN32
367+
return Status.permissions() & sys::fs::perms::owner_exe;
368+
#else
369+
// This isn't the most reliable way but does better than just
370+
// checking owner_exe because most owned files have all_all
371+
// permission regardless of they are executable files.
372+
StringRef FilePath = getFilePath(TreePath, PathStyle);
373+
return (Status.permissions() & sys::fs::perms::owner_exe) &&
374+
(FilePath.ends_with_insensitive(".exe") ||
375+
sys::fs::exists(FilePath + ".exe"));
376+
#endif
377+
}
378+
364379
Expected<FileSystemCache::DirectoryEntry *>
365380
CachingOnDiskFileSystemImpl::makeFile(DirectoryEntry &Parent,
366381
StringRef TreePath, sys::fs::file_t F,
@@ -376,8 +391,8 @@ CachingOnDiskFileSystemImpl::makeFile(DirectoryEntry &Parent,
376391
return Handle.takeError();
377392
// Do not trust Status.size() in case the file is volatile.
378393
return &Cache->makeFile(Parent, TreePathStorage.Path, *Node,
379-
Handle->getData().size(),
380-
Status.permissions() & sys::fs::perms::owner_exe);
394+
Handle->getData().size(),
395+
is_executable(TreePath, Status, Cache->getPathStyle()));
381396
}
382397

383398
Expected<FileSystemCache::DirectoryEntry *>

llvm/utils/lit/lit/TestRunner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,14 @@ def regex_escape(s):
14871487
# a leading slash.
14881488
substitutions.append(("%:" + letter, colonNormalizePath(path)))
14891489

1490+
substitutions.extend(
1491+
[
1492+
# %t (tmpName) in tree path forms for Windows
1493+
("%{t-tree}", "\\" + tmpName if kIsWindows else tmpName),
1494+
("%{t-tree-/}", "/" + tmpName.replace("\\", "/") if kIsWindows else tmpName),
1495+
]
1496+
)
1497+
14901498
return substitutions
14911499

14921500

0 commit comments

Comments
 (0)