File tree Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ def searchForPython(python_implementations):
6969 if num_tests >= CHARM_QUIET_AFTER_NUM_TESTS and '++quiet' not in commonArgs :
7070 additionalArgs .append ('++quiet' )
7171 cmd = ['charmrun/charmrun' ]
72+ if test .get ('prefix' ):
73+ cmd += [test ['prefix' ]]
7274 if not test .get ('interactive' , False ):
7375 cmd += [python ] + [test ['path' ]]
7476 else :
Original file line number Diff line number Diff line change 33import os .path
44
55
6+ def executable_is_python (args ):
7+ """
8+ Determines whether the first executable passed to args is a
9+ Python file. Other valid examples include analysis tools
10+ such as Perf that will run the actual Python program.
11+
12+ Note: Returns true if no executable was found or if an executable
13+ was found and that executable is a Python file.
14+ """
15+ def is_exe (fpath ):
16+ return os .path .isfile (fpath ) and os .access (fpath , os .X_OK )
17+
18+ def is_pyfile (fpath ):
19+ return os .path .isfile (fpath ) and fpath .endswith (".py" )
20+ for each in args :
21+ if is_pyfile (each ):
22+ return True
23+ if is_exe (each ):
24+ return False
25+ # No executable was found, but we'll let Python tell us
26+ return True
27+
28+
629def nodelist_islocal (filename , regexp ):
730 if not os .path .exists (filename ):
831 # it is an error if filename doesn't exist, but I'll let charmrun print
@@ -53,7 +76,11 @@ def start(args=[]):
5376 args += ['-m' , 'charm4py.interactive' ]
5477
5578 cmd = [os .path .join (os .path .dirname (__file__ ), 'charmrun' )]
56- cmd .append (sys .executable ) # for example: /usr/bin/python3
79+ if executable_is_python (args ):
80+ # Note: sys.executable is the absolute path to the Python interpreter
81+ # We only want to invoke the interpreter if the execution target is a
82+ # Python file
83+ cmd .append (sys .executable ) # for example: /usr/bin/python3
5784 cmd .extend (args )
5885 try :
5986 return subprocess .call (cmd )
Original file line number Diff line number Diff line change 288288 {
289289 "path" : " examples/simple/hello_world.py"
290290 },
291+ {
292+ "prefix" : " tests/exec.sh" ,
293+ "path" : " examples/simple/hello_world.py"
294+ },
291295 {
292296 "condition" : " numbaInstalled" ,
293297 "path" : " examples/wave2d/wave2d.py" ,
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Just execute the given command
3+ " $@ "
You can’t perform that action at this time.
0 commit comments