26
26
import json
27
27
import logging
28
28
import os
29
+ import re
29
30
import subprocess
30
31
import sys
31
32
@@ -114,7 +115,7 @@ def find_xcresult_path(project, scheme):
114
115
"""
115
116
project_path = find_project_path (project )
116
117
bundle_dir = os .path .join (project_path , 'Logs/Test' )
117
- prefix = 'Run- ' + scheme + '-'
118
+ prefix = re . compile ( '([^-]*)- ' + re . escape ( scheme ) + '-' )
118
119
119
120
_logger .debug ('Logging for xcresult bundles in %s' , bundle_dir )
120
121
xcresult = find_newest_matching_prefix (bundle_dir , prefix )
@@ -136,7 +137,7 @@ def find_project_path(project):
136
137
The path containing the newest project output.
137
138
"""
138
139
path = os .path .expanduser ('~/Library/Developer/Xcode/DerivedData' )
139
- prefix = project + '-'
140
+ prefix = re . compile ( re . escape ( project ) + '-' )
140
141
141
142
# DerivedData has directories like Firestore-csljdukzqbozahdjizcvrfiufrkb. Use
142
143
# 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):
155
156
156
157
Args:
157
158
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
159
160
160
161
Returns:
161
162
The path to the newest entry in the directory whose basename starts with
@@ -164,7 +165,7 @@ def find_newest_matching_prefix(path, prefix):
164
165
entries = os .listdir (path )
165
166
result = None
166
167
for entry in entries :
167
- if entry . startswith ( prefix ):
168
+ if prefix . match ( entry ):
168
169
fq_entry = os .path .join (path , entry )
169
170
if result is None :
170
171
result = fq_entry
0 commit comments