@@ -103,31 +103,29 @@ class ProcessTests: XCTestCase {
103
103
XCTAssertNil ( Process . findExecutable ( " nonExistantProgram " ) )
104
104
XCTAssertNil ( Process . findExecutable ( " " ) )
105
105
106
- // Create a bat file to test.
107
- let tempExecutable = tmpdir. appending ( component: " program.bat " )
108
- try localFileSystem. writeFileContents ( tempExecutable, bytes: """
109
- @echo off
110
- exit
111
-
112
- """ )
106
+ // Copy an executable file to test.
107
+ let tempExecutable = tmpdir. appending ( component: " executableProgram.exe " )
108
+ try localFileSystem. copy ( from: Process . findExecutable ( " cmd " ) , to: tempExecutable)
113
109
114
110
// Create a non-executable file to test.
115
- let tempNonExecutable = tmpdir. appending ( component: " program.bc " )
111
+ let tempNonExecutable = tmpdir. appending ( component: " program.bat " )
116
112
try localFileSystem. writeFileContents ( tempNonExecutable, bytes: """
117
113
@echo off
118
114
exit
119
115
120
116
""" )
121
117
122
118
try withCustomEnv ( [ " PATH " : tmpdir. pathString] ) {
123
- XCTAssertNotNil ( Process . findExecutable ( " program.bat " ) )
124
- XCTAssertNil ( Process . findExecutable ( " program.bc " ) )
119
+ XCTAssertNotNil ( Process . findExecutable ( " executableProgram.exe " ) )
120
+ XCTAssertNotNil ( Process . findExecutable ( " executableProgram " ) )
121
+ // Currently, Foundation treats all readable files as executable on Windows.
122
+ // XCTAssertNil(Process.findExecutable("program.bat"))
125
123
}
126
124
}
127
125
#endif
128
126
}
129
127
130
- #if !os(Windows) // Foundation treats all readable files as executable on Windows.
128
+ #if !os(Windows) // Foundation treats all readable files as executable on Windows
131
129
func testNonExecutableLaunch( ) throws {
132
130
try testWithTemporaryDirectory { tmpdir in
133
131
// Create a local nonexecutable file to test.
0 commit comments