Run regex match over jobs in memory
The jobs file isn't that big, so it makes sense to read it in once and use it, rather than re-read. Saves a very small amount of time in the test. Change-Id: Id20a2d6926a250f9117108fe32b04fc70b7bfe28
This commit is contained in:
parent
4b7fd514d8
commit
6ee8bfcf1d
@ -92,9 +92,11 @@ def check_formatting():
|
||||
return errors
|
||||
|
||||
def grep(source, pattern):
|
||||
"""Run regex PATTERN over each line in SOURCE and return
|
||||
True if any match found"""
|
||||
found = False
|
||||
p = re.compile(pattern)
|
||||
for line in open(source, "r").readlines():
|
||||
for line in source:
|
||||
if p.match(line):
|
||||
found = True
|
||||
break
|
||||
@ -111,11 +113,15 @@ def check_jobs():
|
||||
# The job-list.txt file is created by tools/run-layout.sh and
|
||||
# thus should exist if this is run from tox. If this is manually invoked
|
||||
# the file might not exist, in that case pass the test.
|
||||
job_list = ".test/job-list.txt"
|
||||
if not os.path.isfile(job_list):
|
||||
job_list_file = ".test/job-list.txt"
|
||||
if not os.path.isfile(job_list_file):
|
||||
print("Job list file %s does not exist, not checking jobs section"
|
||||
% job_list)
|
||||
% job_list_file)
|
||||
return False
|
||||
|
||||
with open(job_list_file, 'r') as f:
|
||||
job_list = [line.rstrip() for line in f]
|
||||
|
||||
for jobs in layout['jobs']:
|
||||
found = grep(job_list, jobs['name'])
|
||||
if not found:
|
||||
|
Loading…
Reference in New Issue
Block a user