Skip to content

Commit 2f19672

Browse files
committed
Test executables against cmd.exe
1 parent cde744f commit 2f19672

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Tests/Foundation/Tests/TestFileManager.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,17 @@ class TestFileManager : XCTestCase {
277277
try fm.setAttributes([.posixPermissions : NSNumber(value: Int16(0o0000))], ofItemAtPath: path)
278278
XCTAssertFalse(fm.isExecutableFile(atPath: path))
279279

280-
// test executable if file has execute permissions
281-
try fm.setAttributes([.posixPermissions : NSNumber(value: Int16(0o0100))], ofItemAtPath: path)
282280
#if os(Windows)
283-
// a Windows executable needs to be binary
284-
XCTAssertFalse(fm.isExecutableFile(atPath: path))
281+
// test against cmd.exe
282+
let systemDir: String = {
283+
var buffer = Array<WCHAR>(repeating: 0, count: Int(MAX_PATH + 1))
284+
GetSystemDirectoryW(&buffer, .init(MAX_PATH + 1))
285+
return String(decodingCString: buffer, as: UTF16.self)
286+
}()
287+
XCTAssertTrue(fm.isExecutableFile(atPath: "\(systemDir)\(pathSep)cmd.exe"))
285288
#else
289+
// test executable if file has execute permissions
290+
try fm.setAttributes([.posixPermissions : NSNumber(value: Int16(0o0100))], ofItemAtPath: path)
286291
XCTAssertTrue(fm.isExecutableFile(atPath: path))
287292
#endif
288293
} catch let e {

0 commit comments

Comments
 (0)