Show More
@@ -521,26 +521,6 b' def escapef(m):' | |||
|
521 | 521 | def stringescape(s): |
|
522 | 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(' $ ') or not 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 | ||
|
544 | 524 | def tsttest(test, wd, options, replacements): |
|
545 | 525 | t = open(test) |
|
546 | 526 | out = [] |
@@ -550,10 +530,24 b' def tsttest(test, wd, options, replaceme' | |||
|
550 | 530 | pos = prepos = -1 |
|
551 | 531 | after = {} |
|
552 | 532 | expected = {} |
|
553 | for n, l in enumerate(transformtst(t)): | |
|
533 | inpython = False | |
|
534 | for n, l in enumerate(t): | |
|
554 | 535 | if not l.endswith('\n'): |
|
555 | 536 | l += '\n' |
|
556 |
if l.startswith(' |
|
|
537 | if l.startswith(' >>> '): | |
|
538 | if not inpython: | |
|
539 | # we've just entered a Python block, add the header | |
|
540 | inpython = True | |
|
541 | script.append('echo %s %s $?\n' % (salt, n)) | |
|
542 | script.append('%s -m heredoctest <<EOF\n' % PYTHON) | |
|
543 | prepos = pos | |
|
544 | pos = n | |
|
545 | after.setdefault(prepos, []).append(l) | |
|
546 | script.append(l[2:]) | |
|
547 | elif l.startswith(' $ '): # commands | |
|
548 | if inpython: | |
|
549 | script.append("EOF\n") | |
|
550 | inpython = False | |
|
557 | 551 | after.setdefault(pos, []).append(l) |
|
558 | 552 | prepos = pos |
|
559 | 553 | pos = n |
@@ -563,12 +557,22 b' def tsttest(test, wd, options, replaceme' | |||
|
563 | 557 | after.setdefault(prepos, []).append(l) |
|
564 | 558 | script.append(l[4:]) |
|
565 | 559 | elif l.startswith(' '): # results |
|
566 | # queue up a list of expected results | |
|
567 |
|
|
|
560 | if inpython: | |
|
561 | script.append(l[2:]) | |
|
562 | after.setdefault(prepos, []).append(l) | |
|
563 | else: | |
|
564 | # queue up a list of expected results | |
|
565 | expected.setdefault(pos, []).append(l[2:]) | |
|
568 | 566 | else: |
|
567 | if inpython: | |
|
568 | script.append("EOF\n") | |
|
569 | inpython = False | |
|
569 | 570 | # non-command/result - queue up for merged output |
|
570 | 571 | after.setdefault(pos, []).append(l) |
|
571 | 572 | |
|
573 | if inpython: | |
|
574 | script.append("EOF\n") | |
|
575 | ||
|
572 | 576 | t.close() |
|
573 | 577 | |
|
574 | 578 | script.append('echo %s %s $?\n' % (salt, n + 1)) |
@@ -853,7 +857,7 b' def runone(options, test):' | |||
|
853 | 857 | refout = None # to match "out is None" |
|
854 | 858 | elif os.path.exists(ref): |
|
855 | 859 | f = open(ref, "r") |
|
856 |
refout = list |
|
|
860 | refout = list(splitnewlines(f.read())) | |
|
857 | 861 | f.close() |
|
858 | 862 | else: |
|
859 | 863 | refout = [] |
General Comments 0
You need to be logged in to leave comments.
Login now