Windows command execution works.

pull/15/head
Jussi Pakkanen 12 years ago
parent e5443493bf
commit c0c2c35496
  1. 11
      interpreter.py
  2. 14
      test cases/common/38 run program/meson.build
  3. 2
      test cases/common/38 run program/scripts/hello.bat

@ -17,7 +17,7 @@ import nodes
import environment import environment
import coredata import coredata
import dependencies import dependencies
import os, sys, platform, copy, subprocess import os, sys, platform, copy, subprocess, shutil
class InterpreterException(coredata.MesonException): class InterpreterException(coredata.MesonException):
pass pass
@ -57,8 +57,13 @@ class RunProcess(InterpreterObject):
return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except FileNotFoundError: except FileNotFoundError:
pass pass
# Was not a command, try to run as a script relative to current dir. # Was not a command, is a program in path?
fullpath = os.path.join(curdir, command_array[0]) exe = shutil.which(cmd_name)
if exe is not None:
command_array = [exe] + command_array[1:]
return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# No? Maybe it is a script in the source tree.
fullpath = os.path.join(curdir, cmd_name)
command_array = [fullpath] + command_array[1:] command_array = [fullpath] + command_array[1:]
try: try:
return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

@ -1,6 +1,11 @@
project('run command', 'c') project('run command', 'c')
c = run_command('echo', 'hello') if host.name() == 'windows'
c = run_command('cmd', '/c', 'echo', 'hello')
else
c = run_command('echo', 'hello')
endif
correct = 'hello' correct = 'hello'
if c.returncode() != 0 if c.returncode() != 0
@ -19,8 +24,11 @@ endif
# Now the same with a script. # Now the same with a script.
cs = run_command('scripts/hello.sh') if host.name() == 'windows'
correct = 'hello' cs = run_command('scripts/hello.bat')
else
cs = run_command('scripts/hello.sh')
endif
if cs.returncode() != 0 if cs.returncode() != 0
error('Executing script failed.') error('Executing script failed.')

Loading…
Cancel
Save