[libcxx-commits] [PATCH] D77500: [libc++] [ssh] Fix tarring test dependencies on Windows
Sergej Jaskiewicz via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 5 07:59:57 PDT 2020
broadwaylamb created this revision.
broadwaylamb added a reviewer: ldionne.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
The motivation for this change is in the comment.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77500
Files:
libcxx/utils/ssh.py
Index: libcxx/utils/ssh.py
===================================================================
--- libcxx/utils/ssh.py
+++ libcxx/utils/ssh.py
@@ -60,17 +60,25 @@
# Ensure the test dependencies exist, tar them up and copy the tarball
# over to the remote host.
- with tempfile.NamedTemporaryFile(suffix='.tar') as tmpTar:
- with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
- for dep in args.dependencies:
- if not os.path.exists(dep):
- sys.stderr.write('Missing file or directory "{}" marked as a dependency of a test'.format(dep))
- return 1
- tarball.add(dep, arcname=os.path.basename(dep))
-
- remoteTarball = pathOnRemote(tmpTar.name)
- tmpTar.flush()
- subprocess.check_call(scp(tmpTar.name, remoteTarball))
+ try:
+ with tempfile.NamedTemporaryFile(suffix='.tar', delete=False) as tmpTar:
+ with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
+ for dep in args.dependencies:
+ if not os.path.exists(dep):
+ sys.stderr.write('Missing file or directory "{}" marked as a dependency of a test'.format(dep))
+ return 1
+ tarball.add(dep, arcname=os.path.basename(dep))
+
+ remoteTarball = pathOnRemote(tmpTar.name)
+ tmpTar.flush()
+ subprocess.check_call(scp(tmpTar.name, remoteTarball))
+ finally:
+ # We delete it manually because otherwise on Windows
+ # it gets deleted before we transfer it to the remote host.
+ # This is because on Windows, file handles with the O_TEMPORARY flag
+ # (which is set if we pass `delete=True`) are deleted as soon as
+ # they're closed.
+ os.remove(tmpTar.name)
# Untar the dependencies in the temporary directory and remove the tarball.
remoteCommands = [
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77500.255164.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200405/861668bd/attachment-0001.bin>
More information about the libcxx-commits
mailing list