@@ -39,6 +39,8 @@ def scp(args, src, dst):
39
39
cmd .extend (shlex .split (args .extra_scp_args ))
40
40
return cmd + [src , "{}:{}" .format (args .host , dst )]
41
41
42
+ def runCommand (command , * args , ** kwargs ):
43
+ return subprocess .run (command , * args , ** kwargs )
42
44
43
45
def main ():
44
46
parser = argparse .ArgumentParser ()
@@ -49,19 +51,25 @@ def main():
49
51
parser .add_argument ("--extra-scp-args" , type = str , required = False )
50
52
parser .add_argument ("--codesign_identity" , type = str , required = False , default = None )
51
53
parser .add_argument ("--env" , type = str , nargs = "*" , required = False , default = [])
52
- parser .add_argument (
53
- "--prepend_env" , type = str , nargs = "*" , required = False , default = []
54
- )
54
+ parser .add_argument ("--prepend_env" , type = str , nargs = "*" , required = False , default = [])
55
+ parser .add_argument ("-v" , "--verbose" , action = 'store_true' )
55
56
parser .add_argument ("command" , nargs = argparse .ONE_OR_MORE )
56
57
args = parser .parse_args ()
57
58
commandLine = args .command
58
59
60
+ def runCommand (command , * args_ , ** kwargs ):
61
+ if args .verbose :
62
+ print (f"$ { ' ' .join (command )} " )
63
+ return subprocess .run (command , * args_ , ** kwargs )
64
+
59
65
# Create a temporary directory where the test will be run.
60
66
# That is effectively the value of %T on the remote host.
61
- tmp = subprocess . check_output (
67
+ tmp = runCommand (
62
68
ssh (args , "mktemp -d {}/libcxx.XXXXXXXXXX" .format (args .tempdir )),
63
69
universal_newlines = True ,
64
- ).strip ()
70
+ check = True ,
71
+ capture_output = True
72
+ ).stdout .strip ()
65
73
66
74
# HACK:
67
75
# If an argument is a file that ends in `.tmp.exe`, assume it is the name
@@ -77,10 +85,8 @@ def main():
77
85
# Do any necessary codesigning of test-executables found in the command line.
78
86
if args .codesign_identity :
79
87
for exe in filter (isTestExe , commandLine ):
80
- subprocess .check_call (
81
- ["xcrun" , "codesign" , "-f" , "-s" , args .codesign_identity , exe ],
82
- env = {},
83
- )
88
+ codesign = ["xcrun" , "codesign" , "-f" , "-s" , args .codesign_identity , exe ]
89
+ runCommand (codesign , env = {}, check = True )
84
90
85
91
# tar up the execution directory (which contains everything that's needed
86
92
# to run the test), and copy the tarball over to the remote host.
@@ -93,7 +99,7 @@ def main():
93
99
# the temporary file while still open doesn't work on Windows.
94
100
tmpTar .close ()
95
101
remoteTarball = pathOnRemote (tmpTar .name )
96
- subprocess . check_call (scp (args , tmpTar .name , remoteTarball ))
102
+ runCommand (scp (args , tmpTar .name , remoteTarball ), check = True )
97
103
finally :
98
104
# Make sure we close the file in case an exception happens before
99
105
# we've closed it above -- otherwise close() is idempotent.
@@ -130,12 +136,12 @@ def main():
130
136
remoteCommands .append (subprocess .list2cmdline (commandLine ))
131
137
132
138
# Finally, SSH to the remote host and execute all the commands.
133
- rc = subprocess . call (ssh (args , " && " .join (remoteCommands )))
139
+ rc = runCommand (ssh (args , " && " .join (remoteCommands ))). returncode
134
140
return rc
135
141
136
142
finally :
137
143
# Make sure the temporary directory is removed when we're done.
138
- subprocess . check_call (ssh (args , "rm -r {}" .format (tmp )))
144
+ runCommand (ssh (args , "rm -r {}" .format (tmp )), check = True )
139
145
140
146
141
147
if __name__ == "__main__" :
0 commit comments