comparison tests/run-tests.py @ 20601:72d843e8cb6d

run-tests: fixed warn detection on failures with too many output The state "warned" was reported too often. The problem fixed here is that warnonly was only reset when a line did not match. When there was a line too much, warnonly remained set. Fix this by setting more states to warnonly. More negative testing (testing on result "Failed") has been done this time.
author Simon Heimberg <simohe@besonet.ch>
date Sun, 16 Feb 2014 23:41:24 +0100
parents 2e68882852ee
children 352abbb0be88
comparison
equal deleted inserted replaced
20600:2e68882852ee 20601:72d843e8cb6d
774 if exitcode == SKIPPED_STATUS or output is None: 774 if exitcode == SKIPPED_STATUS or output is None:
775 return exitcode, output 775 return exitcode, output
776 776
777 # Merge the script output back into a unified test 777 # Merge the script output back into a unified test
778 778
779 warnonly = True 779 warnonly = 1 # 1: not yet, 2: yes, 3: for sure not
780 if exitcode != 0: # failure has been reported
781 warnonly = 3 # set to "for sure not"
780 pos = -1 782 pos = -1
781 postout = [] 783 postout = []
782 for l in output: 784 for l in output:
783 lout, lcmd = l, None 785 lout, lcmd = l, None
784 if salt in l: 786 if salt in l:
809 else: 811 else:
810 if needescape(lout): 812 if needescape(lout):
811 lout = stringescape(lout.rstrip('\n')) + " (esc)\n" 813 lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
812 postout.append(" " + lout) # let diff deal with it 814 postout.append(" " + lout) # let diff deal with it
813 if r != '': # if line failed 815 if r != '': # if line failed
814 warnonly = False 816 warnonly = 3 # set to "for sure not"
817 elif warnonly == 1: # is "not yet" (and line is warn only)
818 warnonly = 2 # set to "yes" do warn
815 819
816 if lcmd: 820 if lcmd:
817 # add on last return code 821 # add on last return code
818 ret = int(lcmd.split()[1]) 822 ret = int(lcmd.split()[1])
819 if ret != 0: 823 if ret != 0:
824 pos = int(lcmd.split()[0]) 828 pos = int(lcmd.split()[0])
825 829
826 if pos in after: 830 if pos in after:
827 postout += after.pop(pos) 831 postout += after.pop(pos)
828 832
829 if warnonly and exitcode == 0: 833 if warnonly == 2:
830 exitcode = False 834 exitcode = False # set exitcode to warned
831 return exitcode, postout 835 return exitcode, postout
832 836
833 wifexited = getattr(os, "WIFEXITED", lambda x: False) 837 wifexited = getattr(os, "WIFEXITED", lambda x: False)
834 def run(cmd, wd, options, replacements, env): 838 def run(cmd, wd, options, replacements, env):
835 """Run command in a sub-process, capturing the output (stdout and stderr). 839 """Run command in a sub-process, capturing the output (stdout and stderr).