Skip to content

Commit 4a861cb

Browse files
committed
Fix ExecTestCase to properly handle shell scripts
Use shell=True to let the shell parse and execute shebangs properly. The previous approach of always using sys.executable broke shell script tests since it tried to run .sh files with the Python interpreter.
1 parent 01fd6cf commit 4a861cb

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

python/subunit/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -907,12 +907,7 @@ def debug(self):
907907

908908
def _run(self, result):
909909
protocol = TestProtocolServer(result)
910-
# Explicitly invoke Python to run the script instead of relying on
911-
# execute permissions, which may not be preserved during installation
912-
import shlex
913-
914-
script_parts = shlex.split(self.script)
915-
process = subprocess.Popen([sys.executable] + script_parts, stdout=subprocess.PIPE)
910+
process = subprocess.Popen(self.script, shell=True, stdout=subprocess.PIPE)
916911
make_stream_binary(process.stdout)
917912
output = process.communicate()[0]
918913
protocol.readFrom(BytesIO(output))

0 commit comments

Comments
 (0)