File tree 4 files changed +37
-1
lines changed
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):
69
69
if num_tests >= CHARM_QUIET_AFTER_NUM_TESTS and '++quiet' not in commonArgs :
70
70
additionalArgs .append ('++quiet' )
71
71
cmd = ['charmrun/charmrun' ]
72
+ if test .get ('prefix' ):
73
+ cmd += [test ['prefix' ]]
72
74
if not test .get ('interactive' , False ):
73
75
cmd += [python ] + [test ['path' ]]
74
76
else :
Original file line number Diff line number Diff line change 3
3
import os .path
4
4
5
5
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
+
6
29
def nodelist_islocal (filename , regexp ):
7
30
if not os .path .exists (filename ):
8
31
# it is an error if filename doesn't exist, but I'll let charmrun print
@@ -53,7 +76,11 @@ def start(args=[]):
53
76
args += ['-m' , 'charm4py.interactive' ]
54
77
55
78
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
57
84
cmd .extend (args )
58
85
try :
59
86
return subprocess .call (cmd )
Original file line number Diff line number Diff line change 288
288
{
289
289
"path" : " examples/simple/hello_world.py"
290
290
},
291
+ {
292
+ "prefix" : " tests/exec.sh" ,
293
+ "path" : " examples/simple/hello_world.py"
294
+ },
291
295
{
292
296
"condition" : " numbaInstalled" ,
293
297
"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