Skip to content

Commit d68bfb6

Browse files
committed
Fix xcresult_logs when run against non-Run configurations
The leading part of the name can be "Run" or "Test" or others.
1 parent a0842fa commit d68bfb6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/xcresult_logs.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import json
2727
import logging
2828
import os
29+
import re
2930
import subprocess
3031
import sys
3132

@@ -114,7 +115,7 @@ def find_xcresult_path(project, scheme):
114115
"""
115116
project_path = find_project_path(project)
116117
bundle_dir = os.path.join(project_path, 'Logs/Test')
117-
prefix = 'Run-' + scheme + '-'
118+
prefix = re.compile('([^-]*)-' + re.escape(scheme) + '-')
118119

119120
_logger.debug('Logging for xcresult bundles in %s', bundle_dir)
120121
xcresult = find_newest_matching_prefix(bundle_dir, prefix)
@@ -136,7 +137,7 @@ def find_project_path(project):
136137
The path containing the newest project output.
137138
"""
138139
path = os.path.expanduser('~/Library/Developer/Xcode/DerivedData')
139-
prefix = project + '-'
140+
prefix = re.compile(re.escape(project) + '-')
140141

141142
# DerivedData has directories like Firestore-csljdukzqbozahdjizcvrfiufrkb. Use
142143
# the most recent one if there are more than one such directory matching the
@@ -155,7 +156,7 @@ def find_newest_matching_prefix(path, prefix):
155156
156157
Args:
157158
path: A directory to list
158-
prefix: The starting part of any filename to consider
159+
prefix: A regular expression that matches the filenames to consider
159160
160161
Returns:
161162
The path to the newest entry in the directory whose basename starts with
@@ -164,7 +165,7 @@ def find_newest_matching_prefix(path, prefix):
164165
entries = os.listdir(path)
165166
result = None
166167
for entry in entries:
167-
if entry.startswith(prefix):
168+
if prefix.match(entry):
168169
fq_entry = os.path.join(path, entry)
169170
if result is None:
170171
result = fq_entry

0 commit comments

Comments
 (0)