@@ -265,8 +265,10 @@ class TestFileManager : XCTestCase {
265
265
func test_isExecutableFile( ) {
266
266
let fm = FileManager . default
267
267
let path = NSTemporaryDirectory ( ) + " test_isExecutableFile \( NSUUID ( ) . uuidString) "
268
+ let exePath = path + " .exe "
268
269
defer {
269
270
try ? fm. removeItem ( atPath: path)
271
+ try ? fm. removeItem ( atPath: exePath)
270
272
}
271
273
272
274
do {
@@ -275,16 +277,21 @@ class TestFileManager : XCTestCase {
275
277
276
278
// test unExecutable if file has no permissions
277
279
try fm. setAttributes ( [ . posixPermissions : NSNumber ( value: Int16 ( 0o0000 ) ) ] , ofItemAtPath: path)
278
- #if os(Windows)
279
- // Files are always executable on Windows
280
- XCTAssertTrue ( fm. isExecutableFile ( atPath: path) )
281
- #else
282
280
XCTAssertFalse ( fm. isExecutableFile ( atPath: path) )
283
- #endif
284
281
282
+ #if os(Windows)
283
+ // test unExecutable even if file has an `exe` extension
284
+ try fm. copyItem ( atPath: path, toPath: exePath)
285
+ XCTAssertFalse ( fm. isExecutableFile ( atPath: exePath) )
286
+ #else
285
287
// test executable if file has execute permissions
286
288
try fm. setAttributes ( [ . posixPermissions : NSNumber ( value: Int16 ( 0o0100 ) ) ] , ofItemAtPath: path)
287
289
XCTAssertTrue ( fm. isExecutableFile ( atPath: path) )
290
+ #endif
291
+
292
+ // test against the test bundle itself
293
+ let testFoundationBinary = try XCTUnwrap ( testBundle ( ) . path ( forAuxiliaryExecutable: " TestFoundation " ) )
294
+ XCTAssertTrue ( fm. isExecutableFile ( atPath: testFoundationBinary) )
288
295
} catch let e {
289
296
XCTFail ( " \( e) " )
290
297
}
0 commit comments