diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-15 11:14:06 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-15 11:14:06 +0900 |
commit | 8a60368b383c269d70fd135694f8b24e6bf216dc (patch) | |
tree | 03f17b157f56a3d696d2bc84bc12f392e2ead105 /testing/runtests.py | |
parent | 6034e81193d784e8af78fa8ab56438ab1e0d7839 (diff) | |
download | doxygen-8a60368b383c269d70fd135694f8b24e6bf216dc.tar.gz doxygen-8a60368b383c269d70fd135694f8b24e6bf216dc.tar.bz2 doxygen-8a60368b383c269d70fd135694f8b24e6bf216dc.zip |
Imported Upstream version 1.8.19upstream/1.8.19
Diffstat (limited to 'testing/runtests.py')
-rwxr-xr-x | testing/runtests.py | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/testing/runtests.py b/testing/runtests.py index 10fe502..6b3e54e 100755 --- a/testing/runtests.py +++ b/testing/runtests.py @@ -150,11 +150,11 @@ class Tester: if (self.args.clang): print('CLANG_ASSISTED_PARSING=YES', file=f) if (self.args.cfgs): - for cfg in list(itertools.chain.from_iterable(self.args.cfgs)): - if cfg.find('=') == -1: + for cfg in self.args.cfgs: + if cfg[0].find('=') == -1: print("Not a doxygen configuration item, missing '=' sign: '%s'."%cfg) sys.exit(1) - print(cfg, file=f) + print(cfg[0], file=f) if 'check' not in self.config or not self.config['check']: print('Test doesn\'t specify any files to check') @@ -183,7 +183,7 @@ class Tester: # 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: @@ -191,12 +191,13 @@ class Tester: 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): @@ -366,10 +367,13 @@ class Tester: if (self.args.pdf): failed_latex=False latex_output='%s/latex' % self.test_out + # with languages like Hungarian we had problems with some tests on windows when stderr was used. if (sys.platform == 'win32'): + outType=False redirl='>nul: 2>temp' mk='make.bat' else: + outType=True redirl='>/dev/null 2>temp' mk='make' cur_directory = os.getcwd() @@ -377,34 +381,43 @@ class Tester: exe_string = mk exe_string1 = exe_string exe_string += ' %s' % (redirl) - exe_string += ' %s more temp' % (separ) - latex_out = xpopen(exe_string,exe_string1,getStderr=True) + if outType: + exe_string += ' %s more temp' % (separ) + latex_out = xpopen(exe_string,exe_string1,getStderr=outType) os.chdir(cur_directory); - if latex_out.find("Error")!=-1: + if (outType and latex_out.find("Error")!=-1): msg += ("PDF generation failed\n For a description of the problem see 'refman.log' in the latex directory of this test",) - failed_html=True - elif xopen(latex_output + "/refman.log",'r').read().find("Error")!= -1: + failed_latex=True + elif (not outType and xopen(latex_output + "/temp",'r').read().find("Error")!= -1): msg += ("PDF generation failed\n For a description of the problem see 'refman.log' in the latex directory of this test",) - failed_html=True - elif xopen(latex_output + "/refman.log",'r').read().find("Emergency stop")!= -1: + failed_latex=True + elif xopen(latex_output + "/refman.log",'r',encoding='ISO-8859-1').read().find("Error")!= -1: msg += ("PDF generation failed\n For a description of the problem see 'refman.log' in the latex directory of this test",) - failed_html=True + failed_latex=True + elif xopen(latex_output + "/refman.log",'r',encoding='ISO-8859-1').read().find("Emergency stop")!= -1: + msg += ("PDF generation failed\n For a description of the problem see 'refman.log' in the latex directory of this test",) + failed_latex=True elif not self.args.keep: shutil.rmtree(latex_output,ignore_errors=True) 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): @@ -419,10 +432,10 @@ class TestManager: 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) @@ -437,9 +450,20 @@ class TestManager: 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) @@ -450,6 +474,14 @@ class TestManager: shutil.rmtree("dtd",ignore_errors=True) shutil.copytree(self.args.inputdir+"/dtd", "dtd") +def split_and_keep(s,sep): + s = s.replace(sep,'\0'+sep) # add token separator + s = s.split('\0') # split by null delimiter + s = [x.strip() for x in filter(None,s)] # strip and remove empty elements + s = [z.split(' ',1) for z in s] # split by first space + s = [i for ss in s for i in ss] # flatten the list + return s + def main(): # argument handling parser = argparse.ArgumentParser(description='run doxygen tests') @@ -476,6 +508,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= @@ -498,7 +532,9 @@ def main(): parser.add_argument('--cfg',nargs='+',dest='cfgs',action='append',help= 'run test with extra doxygen configuration settings ' '(the option may be specified multiple times') - test_flags = os.getenv('TEST_FLAGS', default='').split() + + test_flags = split_and_keep(os.getenv('TEST_FLAGS', default=''), '--') + args = parser.parse_args(test_flags + sys.argv[1:]) # sanity check |