@@ -140,31 +140,29 @@ class ProcessTests: XCTestCase {
140140 XCTAssertNil ( Process . findExecutable ( " nonExistantProgram " ) )
141141 XCTAssertNil ( Process . findExecutable ( " " ) )
142142
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)
150146
151147 // Create a non-executable file to test.
152- let tempNonExecutable = tmpdir. appending ( component: " program.bc " )
148+ let tempNonExecutable = tmpdir. appending ( component: " program.bat " )
153149 try localFileSystem. writeFileContents ( tempNonExecutable, bytes: """
154150 @echo off
155151 exit
156152
157153 """ )
158154
159155 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"))
162160 }
163161 }
164162 #endif
165163 }
166164
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
168166 func testNonExecutableLaunch( ) throws {
169167 try testWithTemporaryDirectory { tmpdir in
170168 // Create a local nonexecutable file to test.
0 commit comments