You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tests/FoundationEssentialsTests/DataIOTests.swift
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -212,8 +212,9 @@ private final class DataIOTests {
212
212
#expect(readData == data)
213
213
}
214
214
215
-
// Atomic writes must succeed when the destination is read-only, and the resulting file must not retain the read-only state.
215
+
// Atomic writes must succeed when the destination is read-only.
216
216
// On POSIX this is the behavior of rename(2). On Windows, SetFileInformationByHandle with FileRenameInfoEx returns ERROR_ACCESS_DENIED for a FILE_ATTRIBUTE_READONLY destination even with FILE_RENAME_FLAG_POSIX_SEMANTICS | FILE_RENAME_FLAG_REPLACE_IF_EXISTS. So the read-only attribute is cleared and the rename is retried.
217
+
// The resulting file retains the read-only attribute. (Not yet on Windows).
@@ -230,12 +231,11 @@ private final class DataIOTests {
230
231
letread=tryData(contentsOf: url)
231
232
#expect(read == next)
232
233
233
-
#if !FOUNDATION_FRAMEWORK
234
-
// The path now resolves to the new temp file (the rename operation detached the old destination). Confirm it's writable by performing a subsequent non-atomic write.
235
-
// Skipped for FOUNDATION_FRAMEWORK: that path preserves and reapplies the destination's pre-rename mode on the new file, so the new file would still be read-only.
236
-
// TODO: Preserve the destination's mode across platforms.
237
-
letlater=Data("later".utf8)
238
-
try later.write(to: url)
234
+
#if !os(Windows)
235
+
// Check mode bits directly. Testing by expecting `try later.write(to: url)` to throw would fail for root (e.g. in Linux CI containers), since root bypasses permission checks even on a read-only file.
0 commit comments