##// END OF EJS Templates
run-tests: finish moving tsttest() into TTest
Gregory Szorc -
r21314:76d7967d default
parent child Browse files
Show More
@@ -747,67 +747,6 b' def linematch(el, l):'
747 return '+glob'
747 return '+glob'
748 return False
748 return False
749
749
750 def tsttest(t, wd, options, salt, after, expected, exitcode, output):
751 # Merge the script output back into a unified test
752
753 warnonly = 1 # 1: not yet, 2: yes, 3: for sure not
754 if exitcode != 0: # failure has been reported
755 warnonly = 3 # set to "for sure not"
756 pos = -1
757 postout = []
758 for l in output:
759 lout, lcmd = l, None
760 if salt in l:
761 lout, lcmd = l.split(salt, 1)
762
763 if lout:
764 if not lout.endswith('\n'):
765 lout += ' (no-eol)\n'
766
767 # find the expected output at the current position
768 el = None
769 if pos in expected and expected[pos]:
770 el = expected[pos].pop(0)
771
772 r = linematch(el, lout)
773 if isinstance(r, str):
774 if r == '+glob':
775 lout = el[:-1] + ' (glob)\n'
776 r = '' # warn only this line
777 elif r == '-glob':
778 lout = ''.join(el.rsplit(' (glob)', 1))
779 r = '' # warn only this line
780 else:
781 log('\ninfo, unknown linematch result: %r\n' % r)
782 r = False
783 if r:
784 postout.append(" " + el)
785 else:
786 if needescape(lout):
787 lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
788 postout.append(" " + lout) # let diff deal with it
789 if r != '': # if line failed
790 warnonly = 3 # set to "for sure not"
791 elif warnonly == 1: # is "not yet" (and line is warn only)
792 warnonly = 2 # set to "yes" do warn
793
794 if lcmd:
795 # add on last return code
796 ret = int(lcmd.split()[1])
797 if ret != 0:
798 postout.append(" [%s]\n" % ret)
799 if pos in after:
800 # merge in non-active test bits
801 postout += after.pop(pos)
802 pos = int(lcmd.split()[0])
803
804 if pos in after:
805 postout += after.pop(pos)
806
807 if warnonly == 2:
808 exitcode = False # set exitcode to warned
809 return exitcode, postout
810
811 class TTest(Test):
750 class TTest(Test):
812 """A "t test" is a test backed by a .t file."""
751 """A "t test" is a test backed by a .t file."""
813
752
@@ -834,8 +773,7 b' class TTest(Test):'
834 if exitcode == SKIPPED_STATUS or output is None:
773 if exitcode == SKIPPED_STATUS or output is None:
835 return exitcode, output
774 return exitcode, output
836
775
837 return tsttest(self, testtmp, self._options, salt, after, expected,
776 return self._processoutput(exitcode, output, salt, after, expected)
838 exitcode, output)
839
777
840 def _hghave(self, reqs, testtmp):
778 def _hghave(self, reqs, testtmp):
841 # TODO do something smarter when all other uses of hghave are gone.
779 # TODO do something smarter when all other uses of hghave are gone.
@@ -959,6 +897,67 b' class TTest(Test):'
959
897
960 return salt, script, after, expected
898 return salt, script, after, expected
961
899
900 def _processoutput(self, exitcode, output, salt, after, expected):
901 # Merge the script output back into a unified test.
902 warnonly = 1 # 1: not yet; 2: yes; 3: for sure not
903 if exitcode != 0:
904 warnonly = 3
905
906 pos = -1
907 postout = []
908 for l in output:
909 lout, lcmd = l, None
910 if salt in l:
911 lout, lcmd = l.split(salt, 1)
912
913 if lout:
914 if not lout.endswith('\n'):
915 lout += ' (no-eol)\n'
916
917 # Find the expected output at the current position.
918 el = None
919 if expected.get(pos, None):
920 el = expected[pos].pop(0)
921
922 r = linematch(el, lout)
923 if isinstance(r, str):
924 if r == '+glob':
925 lout = el[:-1] + ' (glob)\n'
926 r = '' # Warn only this line.
927 elif r == '-glob':
928 lout = ''.join(el.rsplit(' (glob)', 1))
929 r = '' # Warn only this line.
930 else:
931 log('\ninfo, unknown linematch result: %r\n' % r)
932 r = False
933 if r:
934 postout.append(' ' + el)
935 else:
936 if needescape(lout):
937 lout = stringescape(lout.rstrip('\n')) + ' (esc)\n'
938 postout.append(' ' + lout) # Let diff deal with it.
939 if r != '': # If line failed.
940 warnonly = 3 # for sure not
941 elif warnonly == 1: # Is "not yet" and line is warn only.
942 warnonly = 2 # Yes do warn.
943
944 if lcmd:
945 # Add on last return code.
946 ret = int(lcmd.split()[1])
947 if ret != 0:
948 postout.append(' [%s]\n' % ret)
949 if pos in after:
950 # Merge in non-active test bits.
951 postout += after.pop(pos)
952 pos = int(lcmd.split()[0])
953
954 if pos in after:
955 postout += after.pop(pos)
956
957 if warnonly == 2:
958 exitcode = False # Set exitcode to warned.
959
960 return exitcode, postout
962
961
963 wifexited = getattr(os, "WIFEXITED", lambda x: False)
962 wifexited = getattr(os, "WIFEXITED", lambda x: False)
964 def run(cmd, wd, options, replacements, env):
963 def run(cmd, wd, options, replacements, env):
General Comments 0
You need to be logged in to leave comments. Login now