@@ -103,31 +103,29 @@ class ProcessTests: XCTestCase {
103103 XCTAssertNil ( Process . findExecutable ( " nonExistantProgram " ) )
104104 XCTAssertNil ( Process . findExecutable ( " " ) )
105105
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)
113109
114110 // Create a non-executable file to test.
115- let tempNonExecutable = tmpdir. appending ( component: " program.bc " )
111+ let tempNonExecutable = tmpdir. appending ( component: " program.bat " )
116112 try localFileSystem. writeFileContents ( tempNonExecutable, bytes: """
117113 @echo off
118114 exit
119115
120116 """ )
121117
122118 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"))
125123 }
126124 }
127125 #endif
128126 }
129127
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
131129 func testNonExecutableLaunch( ) throws {
132130 try testWithTemporaryDirectory { tmpdir in
133131 // Create a local nonexecutable file to test.
0 commit comments