equal
deleted
inserted
replaced
519 def escapef(m): |
519 def escapef(m): |
520 return escapemap[m.group(0)] |
520 return escapemap[m.group(0)] |
521 def stringescape(s): |
521 def stringescape(s): |
522 return escapesub(escapef, s) |
522 return escapesub(escapef, s) |
523 |
523 |
|
524 def transformtst(lines): |
|
525 inblock = False |
|
526 for l in lines: |
|
527 if inblock: |
|
528 if l.startswith(' $ '): |
|
529 inblock = False |
|
530 yield ' > EOF\n' |
|
531 yield l |
|
532 else: |
|
533 yield ' > ' + l[2:] |
|
534 else: |
|
535 if l.startswith(' >>> '): |
|
536 inblock = True |
|
537 yield ' $ %s -m heredoctest <<EOF\n' % PYTHON |
|
538 yield ' > ' + l[2:] |
|
539 else: |
|
540 yield l |
|
541 if inblock: |
|
542 yield ' > EOF\n' |
|
543 |
524 def tsttest(test, wd, options, replacements): |
544 def tsttest(test, wd, options, replacements): |
525 t = open(test) |
545 t = open(test) |
526 out = [] |
546 out = [] |
527 script = [] |
547 script = [] |
528 salt = "SALT" + str(time.time()) |
548 salt = "SALT" + str(time.time()) |
529 |
549 |
530 pos = prepos = -1 |
550 pos = prepos = -1 |
531 after = {} |
551 after = {} |
532 expected = {} |
552 expected = {} |
533 for n, l in enumerate(t): |
553 for n, l in enumerate(transformtst(t)): |
534 if not l.endswith('\n'): |
554 if not l.endswith('\n'): |
535 l += '\n' |
555 l += '\n' |
536 if l.startswith(' $ '): # commands |
556 if l.startswith(' $ '): # commands |
537 after.setdefault(pos, []).append(l) |
557 after.setdefault(pos, []).append(l) |
538 prepos = pos |
558 prepos = pos |
831 # check test output against it. |
851 # check test output against it. |
832 if options.debug: |
852 if options.debug: |
833 refout = None # to match "out is None" |
853 refout = None # to match "out is None" |
834 elif os.path.exists(ref): |
854 elif os.path.exists(ref): |
835 f = open(ref, "r") |
855 f = open(ref, "r") |
836 refout = splitnewlines(f.read()) |
856 refout = list(transformtst(splitnewlines(f.read()))) |
837 f.close() |
857 f.close() |
838 else: |
858 else: |
839 refout = [] |
859 refout = [] |
840 |
860 |
841 if (ret != 0 or out != refout) and not skipped and not options.debug: |
861 if (ret != 0 or out != refout) and not skipped and not options.debug: |