Update the remote test launch utility (utils/remote-exec.py).
Allowed a single file execution without the execution directory.
This commit is contained in:
parent
220185552f
commit
20e1efcfe1
|
@ -41,7 +41,7 @@ def scp(args, src, dst):
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--host', type=str, required=True)
|
parser.add_argument('--host', type=str, required=True)
|
||||||
parser.add_argument('--execdir', type=str, required=True)
|
parser.add_argument('--execdir', type=str, required=False)
|
||||||
parser.add_argument('--extra-ssh-args', type=str, required=False)
|
parser.add_argument('--extra-ssh-args', type=str, required=False)
|
||||||
parser.add_argument('--extra-scp-args', type=str, required=False)
|
parser.add_argument('--extra-scp-args', type=str, required=False)
|
||||||
parser.add_argument('--codesign_identity', type=str, required=False, default=None)
|
parser.add_argument('--codesign_identity', type=str, required=False, default=None)
|
||||||
|
@ -55,7 +55,7 @@ def main():
|
||||||
# and changing their path when running on the remote host. It's also possible
|
# and changing their path when running on the remote host. It's also possible
|
||||||
# for there to be no such executable, for example in the case of a .sh.cpp
|
# for there to be no such executable, for example in the case of a .sh.cpp
|
||||||
# test.
|
# test.
|
||||||
parser.add_argument('--exec-pattern', type=str, required=False, default='.*\.tmp\.exe',
|
parser.add_argument('--exec-pattern', type=str, required=False, default='.*',
|
||||||
help='The name regex pattern of the executables generated by \
|
help='The name regex pattern of the executables generated by \
|
||||||
a test file. Specifying it allows us to do custom \
|
a test file. Specifying it allows us to do custom \
|
||||||
processing like codesigning test-executables \
|
processing like codesigning test-executables \
|
||||||
|
@ -68,6 +68,15 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
commandLine = args.command
|
commandLine = args.command
|
||||||
|
|
||||||
|
execdir = args.execdir
|
||||||
|
if execdir == '.':
|
||||||
|
# Retrieve the exec directory from the command line.
|
||||||
|
execdir, _ = os.path.split(commandLine[0])
|
||||||
|
if execdir == '':
|
||||||
|
# Get the current directory in that case.
|
||||||
|
execdir = os.getcwd()
|
||||||
|
arcname = os.path.basename(execdir) if execdir else None
|
||||||
|
|
||||||
# Create a temporary directory where the test will be run.
|
# Create a temporary directory where the test will be run.
|
||||||
# That is effectively the value of %T on the remote host.
|
# That is effectively the value of %T on the remote host.
|
||||||
tmp = subprocess.check_output(
|
tmp = subprocess.check_output(
|
||||||
|
@ -78,6 +87,8 @@ def main():
|
||||||
isExecutable = lambda exe: re.match(args.exec_pattern, exe) and os.path.exists(exe)
|
isExecutable = lambda exe: re.match(args.exec_pattern, exe) and os.path.exists(exe)
|
||||||
pathOnRemote = lambda file: posixpath.join(tmp, os.path.basename(file))
|
pathOnRemote = lambda file: posixpath.join(tmp, os.path.basename(file))
|
||||||
|
|
||||||
|
remoteCommands = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Do any necessary codesigning of test-executables found in the command line.
|
# Do any necessary codesigning of test-executables found in the command line.
|
||||||
if args.codesign_identity:
|
if args.codesign_identity:
|
||||||
|
@ -88,10 +99,11 @@ def main():
|
||||||
|
|
||||||
# tar up the execution directory (which contains everything that's needed
|
# tar up the execution directory (which contains everything that's needed
|
||||||
# to run the test), and copy the tarball over to the remote host.
|
# to run the test), and copy the tarball over to the remote host.
|
||||||
|
if execdir:
|
||||||
try:
|
try:
|
||||||
tmpTar = tempfile.NamedTemporaryFile(suffix='.tar', delete=False)
|
tmpTar = tempfile.NamedTemporaryFile(suffix='.tar', delete=False)
|
||||||
with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
|
with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
|
||||||
tarball.add(args.execdir, arcname=os.path.basename(args.execdir))
|
tarball.add(execdir, arcname=arcname)
|
||||||
|
|
||||||
# Make sure we close the file before we scp it, because accessing
|
# Make sure we close the file before we scp it, because accessing
|
||||||
# the temporary file while still open doesn't work on Windows.
|
# the temporary file while still open doesn't work on Windows.
|
||||||
|
@ -105,10 +117,16 @@ def main():
|
||||||
os.remove(tmpTar.name)
|
os.remove(tmpTar.name)
|
||||||
|
|
||||||
# Untar the dependencies in the temporary directory and remove the tarball.
|
# Untar the dependencies in the temporary directory and remove the tarball.
|
||||||
remoteCommands = [
|
remoteCommands.extend([
|
||||||
'tar -xf {} -C {} --strip-components 1'.format(remoteTarball, tmp),
|
'tar -xf {} -C {} --strip-components 1'.format(remoteTarball, tmp),
|
||||||
'rm {}'.format(remoteTarball)
|
'rm {}'.format(remoteTarball)
|
||||||
]
|
])
|
||||||
|
else:
|
||||||
|
# Copy only the files, which are specified in the command line.
|
||||||
|
# Copy them to remote host one by one.
|
||||||
|
for x in commandLine:
|
||||||
|
_, f = os.path.split(x)
|
||||||
|
subprocess.check_call(scp(args, x, pathOnRemote(f)))
|
||||||
|
|
||||||
# Make sure all executables in the remote command line have 'execute'
|
# Make sure all executables in the remote command line have 'execute'
|
||||||
# permissions on the remote host. The host that compiled the test-executable
|
# permissions on the remote host. The host that compiled the test-executable
|
||||||
|
|
Loading…
Reference in New Issue