[libcxx-commits] [libcxx] 232d3a3 - [libc++] Fix codesigning in run.py

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 1 10:40:01 PDT 2021


Author: Louis Dionne
Date: 2021-04-01T13:39:49-04:00
New Revision: 232d3a3e4755057b51cec1c4c5eaa7ecdec9e70a

URL: https://github.com/llvm/llvm-project/commit/232d3a3e4755057b51cec1c4c5eaa7ecdec9e70a
DIFF: https://github.com/llvm/llvm-project/commit/232d3a3e4755057b51cec1c4c5eaa7ecdec9e70a.diff

LOG: [libc++] Fix codesigning in run.py

Without this patch, we'd always try to codesign the first argument in
the command line, which in some cases is not something we can codesign
(e.g. `bash` for some .sh.cpp tests).

Note that this "hack" is the same thing we do in `ssh.py` - we might need
to admit that it's not a hack after all in the future, but I'm not ready
for that yet.

Differential Revision: https://reviews.llvm.org/D99726

Added: 
    

Modified: 
    libcxx/utils/run.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/run.py b/libcxx/utils/run.py
index 6d88e500b3f6..92d0accd3a9a 100755
--- a/libcxx/utils/run.py
+++ b/libcxx/utils/run.py
@@ -29,13 +29,18 @@ def main():
     args = parser.parse_args()
     commandLine = args.command
 
-    # Do any necessary codesigning.
+    # HACK:
+    # If an argument is a file that ends in `.tmp.exe`, assume it is the name
+    # of an executable generated by a test file. We call these test-executables
+    # below. This allows us to do custom processing like codesigning test-executables.
+    # It's also possible for there to be no such executable, for example in the case
+    # of a .sh.cpp test.
+    isTestExe = lambda exe: exe.endswith('.tmp.exe') and os.path.exists(exe)
+
+    # Do any necessary codesigning of test-executables found in the command line.
     if args.codesign_identity:
-        exe = commandLine[0]
-        rc = subprocess.call(['xcrun', 'codesign', '-f', '-s', args.codesign_identity, exe], env={})
-        if rc != 0:
-            sys.stderr.write('Failed to codesign: ' + exe)
-            return rc
+        for exe in filter(isTestExe, commandLine):
+            subprocess.check_call(['xcrun', 'codesign', '-f', '-s', args.codesign_identity, exe], env={})
 
     # Extract environment variables into a dictionary
     env = {k : v  for (k, v) in map(lambda s: s.split('=', 1), args.env)}


        


More information about the libcxx-commits mailing list