Skip to content

Commit 4193eb6

Browse files
committed
Generate shorter tmp directory names on Windows
1 parent b60f7dd commit 4193eb6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/_InternalTestSupport/misc.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ public func testWithTemporaryDirectory<Result>(
9797
.replacing(")", with: "")
9898
.replacing(".", with: "")
9999
.replacing(":", with: "_")
100-
return try await withTemporaryDirectory(prefix: "spm-tests-\(cleanedFunction)") { tmpDirPath in
100+
101+
// Use shorter prefix on Windows to avoid MAX_PATH issues
102+
#if os(Windows)
103+
let prefix = "spm-\(abs(cleanedFunction.hashValue))"
104+
#else
105+
let prefix = "spm-tests-\(cleanedFunction)"
106+
#endif
107+
108+
return try await withTemporaryDirectory(prefix: prefix) { tmpDirPath in
101109
defer {
102110
// Unblock and remove the tmp dir on deinit.
103111
try? localFileSystem.chmod(.userWritable, path: tmpDirPath, options: [.recursive])

0 commit comments

Comments
 (0)