From d0ba4ced4b265c19c863f7a0c1db8b1d3a8c7b5a Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Tue, 16 May 2023 14:55:03 -0700 Subject: [PATCH] tests: Fix module loading prefer-serialized test failure on Windows Fixes three tests failing on Windows: ``` Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-archs.swift Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode-framework.swift Swift(windows-x86_64) :: ModuleInterface/ModuleCache/force-module-loading-mode.swift ``` These test cases remove read access to the `.swiftmodule` . The expected behavior is that the compiler checks `fs.exists("path-to.swiftmodule")` , determines that the file exists and chooses to use it instead of the `.swiftinterface`. Compilation then fails because the file cannot be read. https://github.com/apple/swift/blob/e22cf2e993267639ad8875707cadf401eb97d98b/lib/Frontend/ModuleInterfaceLoader.cpp#L752 On Windows, we were denying `R` access, which is broader than only read access to file contents but also includes file attributes and permissions. This caused `fs.exists` to fail since it relies on `fs.status`, which could not open the file with `CreateFileW`. The fix is is to only deny `RD - read data/list directory` access. --- test/ModuleInterface/Inputs/make-unreadable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ModuleInterface/Inputs/make-unreadable.py b/test/ModuleInterface/Inputs/make-unreadable.py index 6a90d3ae511af..c8af100827864 100644 --- a/test/ModuleInterface/Inputs/make-unreadable.py +++ b/test/ModuleInterface/Inputs/make-unreadable.py @@ -30,7 +30,7 @@ for path in sys.argv[1:]: subprocess.call(['icacls', path, '/deny', - '{}:(R)'.format(user_name)]) + '{}:(RD)'.format(user_name)]) else: for path in sys.argv[1:]: subprocess.call(['chmod', 'a-r', path])