tests/heredoctest.py
author Simon Heimberg <simohe@besonet.ch>
Thu, 16 Jan 2014 12:08:57 +0100
branchstable
changeset 1321 79f68c0ed71e
parent 1110 d5b3404b82ce
permissions -rw-r--r--
run-tests: print more information on unnecessary glob matching Extend the message with the test name and the approximate line number. (The line number is the one of the command producing the output.) Finding the line to fix is easier now. old message: ...... Info, unnecessary glob: at a/b/c (glob) .. new message: ...... Info, unnecessary glob in test-example.t (after line 9): at a/b/c (glob) .. The test result is still pass as before. [ original upstream message ]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1110
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     1
import sys
1108
168da136346a tests: remove temp doctest file when finished running it
Idan Kamara <idankk86@gmail.com>
parents: 1107
diff changeset
     2
1110
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     3
globalvars = {}
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     4
localvars = {}
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     5
lines = sys.stdin.readlines()
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     6
while lines:
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     7
    l = lines.pop(0)
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     8
    if l.startswith('SALT'):
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
     9
        print l[:-1]
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    10
    elif l.startswith('>>> '):
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    11
        snippet = l[4:]
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    12
        while lines and lines[0].startswith('... '):
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    13
            l = lines.pop(0)
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    14
            snippet += "\n" + l[4:]
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    15
        c = compile(snippet, '<heredoc>', 'single')
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    16
        try:
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    17
            exec c in globalvars, localvars
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    18
        except Exception, inst:
d5b3404b82ce run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents: 1109
diff changeset
    19
            print repr(inst)