@@ -140,31 +140,29 @@ class ProcessTests: XCTestCase {
140
140
XCTAssertNil ( Process . findExecutable ( " nonExistantProgram " ) )
141
141
XCTAssertNil ( Process . findExecutable ( " " ) )
142
142
143
- // Create a bat file to test.
144
- let tempExecutable = tmpdir. appending ( component: " program.bat " )
145
- try localFileSystem. writeFileContents ( tempExecutable, bytes: """
146
- @echo off
147
- exit
148
-
149
- """ )
143
+ // Copy an executable file to test.
144
+ let tempExecutable = tmpdir. appending ( component: " executableProgram.exe " )
145
+ try localFileSystem. copy ( from: Process . findExecutable ( " cmd " ) !, to: tempExecutable)
150
146
151
147
// Create a non-executable file to test.
152
- let tempNonExecutable = tmpdir. appending ( component: " program.bc " )
148
+ let tempNonExecutable = tmpdir. appending ( component: " program.bat " )
153
149
try localFileSystem. writeFileContents ( tempNonExecutable, bytes: """
154
150
@echo off
155
151
exit
156
152
157
153
""" )
158
154
159
155
try withCustomEnv ( [ " PATH " : tmpdir. pathString] ) {
160
- XCTAssertNotNil ( Process . findExecutable ( " program.bat " ) )
161
- XCTAssertNil ( Process . findExecutable ( " program.bc " ) )
156
+ XCTAssertNotNil ( Process . findExecutable ( " executableProgram.exe " ) )
157
+ XCTAssertNotNil ( Process . findExecutable ( " executableProgram " ) )
158
+ // Currently, Foundation treats all readable files as executable on Windows.
159
+ // XCTAssertNil(Process.findExecutable("program.bat"))
162
160
}
163
161
}
164
162
#endif
165
163
}
166
164
167
- #if !os(Windows) // Foundation treats all readable files as executable on Windows.
165
+ #if !os(Windows) // Foundation treats all readable files as executable on Windows
168
166
func testNonExecutableLaunch( ) throws {
169
167
try testWithTemporaryDirectory { tmpdir in
170
168
// Create a local nonexecutable file to test.
0 commit comments