Skip to content

Commit

Permalink
Addon option --pool to the test run script for parallel execution of …
Browse files Browse the repository at this point in the history
…tests (#7827)

To make better use of the processors of a computer the possibility has been build to execute the tests in parallel, this is especially of an advantage for PDF tests.
To make use of this option the number of parallel tests `np` has to be specified by means of `--pool=np`, the default is 1.
  • Loading branch information
albert-github committed Jun 13, 2020
1 parent 963b8da commit 42e36bd
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions testing/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,21 @@ def update_test(self,testmgr):
# check if the file we need to check is actually generated
if not os.path.isfile(check_file):
print('Non-existing file %s after \'check:\' statement' % check_file)
return
return False
# convert output to canonical form
data = xpopen('%s --format --noblanks --nowarning %s' % (self.args.xmllint,check_file))
if data:
# strip version
data = re.sub(r'xsd" version="[0-9.-]+"','xsd" version=""',data).rstrip('\n')
else:
print('Failed to run %s on the doxygen output file %s' % (self.args.xmllint,self.test_out))
return
return False
out_file='%s/%s' % (self.test_out,check)
with xopen(out_file,'w') as f:
print(data,file=f)
shutil.rmtree(self.test_out+'/out',ignore_errors=True)
os.remove(self.test_out+'/Doxyfile')
return True

# check the relevant files of a doxygen run with the reference material
def perform_test(self,testmgr):
Expand Down Expand Up @@ -401,17 +402,22 @@ def perform_test(self,testmgr):

if failed_xml or failed_html or failed_latex or failed_docbook or failed_rtf or failed_xmlxsd:
testmgr.ok(False,self.test_name,msg)
return
return False

testmgr.ok(True,self.test_name)
if not self.args.keep:
shutil.rmtree(self.test_out,ignore_errors=True)
return True

def run(self,testmgr):
if self.update:
self.update_test(testmgr)
return self.update_test(testmgr)
else:
self.perform_test(testmgr)
return self.perform_test(testmgr)

def do_generation_work(test):
tester = Tester(test[0].args,test[1])
return tester.run(test[0])

class TestManager:
def __init__(self,args,tests):
Expand All @@ -426,10 +432,10 @@ def __init__(self,args,tests):

def ok(self,result,test_name,msg='Ok'):
if result:
print('ok %s - %s' % (self.count,test_name))
print('ok - %s' % (test_name))
self.passed = self.passed + 1
else:
print('not ok %s - %s' % (self.count,test_name))
print('not ok - %s' % (test_name))
print('-------------------------------------')
for o in msg:
print(o)
Expand All @@ -444,9 +450,20 @@ def result(self):
return 0 if self.passed==self.num_tests else 1

def perform_tests(self):
for test in self.tests:
tester = Tester(self.args,test)
tester.run(self)
if (self.args.pool == 1):
passed = 0
for test in self.tests:
tester = Tester(self.args,test)
passed += tester.run(self)
self.passed = passed
else:
dl = []
for test in self.tests:
dl += [(self, test)]
import multiprocessing as mp
p = mp.Pool(processes=self.args.pool)
passed = p.map(do_generation_work, dl)
self.passed = sum(passed)
res=self.result()
if self.args.xhtml and self.args.inputdir!='.' and not res and not self.args.keep:
shutil.rmtree("dtd",ignore_errors=True)
Expand Down Expand Up @@ -483,6 +500,8 @@ def main():
'output directory to write the doxygen output to')
parser.add_argument('--noredir',help=
'disable redirection of doxygen warnings',action="store_true")
parser.add_argument('--pool',nargs='?',default='1',type=int,help=
'pool size of multiprocess tests')
parser.add_argument('--xml',help='create xml output and check',
action="store_true")
parser.add_argument('--rtf',help=
Expand Down

0 comments on commit 42e36bd

Please sign in to comment.