Skip to content

Commit 232d3a3

Browse files
committed
[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
1 parent 6b05d75 commit 232d3a3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libcxx/utils/run.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ def main():
2929
args = parser.parse_args()
3030
commandLine = args.command
3131

32-
# Do any necessary codesigning.
32+
# HACK:
33+
# If an argument is a file that ends in `.tmp.exe`, assume it is the name
34+
# of an executable generated by a test file. We call these test-executables
35+
# below. This allows us to do custom processing like codesigning test-executables.
36+
# It's also possible for there to be no such executable, for example in the case
37+
# of a .sh.cpp test.
38+
isTestExe = lambda exe: exe.endswith('.tmp.exe') and os.path.exists(exe)
39+
40+
# Do any necessary codesigning of test-executables found in the command line.
3341
if args.codesign_identity:
34-
exe = commandLine[0]
35-
rc = subprocess.call(['xcrun', 'codesign', '-f', '-s', args.codesign_identity, exe], env={})
36-
if rc != 0:
37-
sys.stderr.write('Failed to codesign: ' + exe)
38-
return rc
42+
for exe in filter(isTestExe, commandLine):
43+
subprocess.check_call(['xcrun', 'codesign', '-f', '-s', args.codesign_identity, exe], env={})
3944

4045
# Extract environment variables into a dictionary
4146
env = {k : v for (k, v) in map(lambda s: s.split('=', 1), args.env)}

0 commit comments

Comments
 (0)