tests/run-tests.py
changeset 1349 42b428c5fcd8
parent 1348 2cb27f4b641c
child 1350 f541c0ba771c
equal deleted inserted replaced
1345:ea8abd9436ee 1349:42b428c5fcd8
   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:
   795 
   797 
   796             r = linematch(el, lout)
   798             r = linematch(el, lout)
   797             if isinstance(r, str):
   799             if isinstance(r, str):
   798                 if r == '+glob':
   800                 if r == '+glob':
   799                     lout = el[:-1] + ' (glob)\n'
   801                     lout = el[:-1] + ' (glob)\n'
   800                     r = 0 # warn only
   802                     r = '' # warn only this line
   801                 elif r == '-glob':
   803                 elif r == '-glob':
   802                     lout = ''.join(el.rsplit(' (glob)', 1))
   804                     lout = ''.join(el.rsplit(' (glob)', 1))
   803                     r = 0 # warn only
   805                     r = '' # warn only this line
   804                 else:
   806                 else:
   805                     log('\ninfo, unknown linematch result: %r\n' % r)
   807                     log('\ninfo, unknown linematch result: %r\n' % r)
   806                     r = False
   808                     r = False
   807             if r:
   809             if r:
   808                 postout.append("  " + el)
   810                 postout.append("  " + el)
   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 != 0: # != warn only
   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).