diff options
Diffstat (limited to 'testing/runtests.py')
-rwxr-xr-x | testing/runtests.py | 119 |
1 files changed, 95 insertions, 24 deletions
diff --git a/testing/runtests.py b/testing/runtests.py index 10fe502..fde252d 100755 --- a/testing/runtests.py +++ b/testing/runtests.py @@ -35,6 +35,26 @@ def xpopen(cmd, cmd1="",encoding='utf-8-sig', getStderr=False): proc = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr=subprocess.PIPE,encoding=encoding) # Python 3 with encoding return proc.stdout.read() +def clean_header(errmsg): + # messages (due to the usage of more) have a contents like: + # :::::::::::: + # <file name> + # :::::::::::: + # we want to skip these + msg = errmsg.split('\n') + rtnmsg = "" + cnt = -1 + for o in msg: + if (o): + if (cnt == -1): + if o.startswith(":::::::"): + cnt = 3 + if (cnt > 0): + cnt-=1 + else: + rtnmsg+=0 + return rtnmsg + class Tester: def __init__(self,args,test): self.args = args @@ -118,6 +138,7 @@ class Tester: print('INPUT=%s/%s' % (self.args.inputdir,self.test), file=f) print('STRIP_FROM_PATH=%s' % self.args.inputdir, file=f) print('EXAMPLE_PATH=%s' % self.args.inputdir, file=f) + print('WARN_LOGFILE=%s/warnings.log' % self.test_out, file=f) if 'config' in self.config: for option in self.config['config']: print(option, file=f) @@ -150,11 +171,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') @@ -162,7 +183,7 @@ class Tester: # run doxygen if (sys.platform == 'win32'): - redir=' > nul:' + redir=' > nul: 2>&1' else: redir=' 2> /dev/null > /dev/null' @@ -183,7 +204,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 +212,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): @@ -278,6 +300,8 @@ class Tester: msg += ('Failed to run %s with schema %s for files: %s' % (self.args.xmllint,index_xsd,index_xml),) failed_xmlxsd=True if xmllint_out: + xmllint_out = clean_header(xmllint_out) + if xmllint_out: msg += (xmllint_out,) failed_xmlxsd=True # @@ -304,6 +328,8 @@ class Tester: msg += ('Failed to run %s with schema %s for files: %s' % (self.args.xmllint,compound_xsd,compound_xml),) failed_xmlxsd=True if xmllint_out: + xmllint_out = clean_header(xmllint_out) + if xmllint_out: msg += (xmllint_out,) failed_xmlxsd=True @@ -336,6 +362,8 @@ class Tester: xmllint_out = xpopen(exe_string,exe_string1,getStderr=True) xmllint_out = self.cleanup_xmllint_docbook(xmllint_out) if xmllint_out: + xmllint_out = clean_header(xmllint_out) + if xmllint_out: msg += (xmllint_out,) failed_docbook=True elif not self.args.keep: @@ -359,6 +387,8 @@ class Tester: xmllint_out = xpopen(exe_string,exe_string1,getStderr=True) xmllint_out = self.cleanup_xmllint(xmllint_out) if xmllint_out: + xmllint_out = clean_header(xmllint_out) + if xmllint_out: msg += (xmllint_out,) failed_html=True elif not self.args.keep: @@ -366,10 +396,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 +410,48 @@ 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: + warnings = xopen(self.test_out + "/warnings.log",'r',encoding='ISO-8859-1').read() + failed_warn = len(warnings)!=0 + if failed_warn: + msg += (warnings,) + + if failed_warn or 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 +466,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 +484,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 +508,15 @@ class TestManager: shutil.rmtree("dtd",ignore_errors=True) shutil.copytree(self.args.inputdir+"/dtd", "dtd") +def split_and_keep(s,sep): + s = s.replace('"','') # add token separator + 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 +543,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 +567,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 |