micropython

Annotated test_all.py

234:77038806cb40
2009-06-01 Paul Boddie Moved context verification back into the invocation code, as opposed to residing in the function body code. This is required because keyword arguments need to operate on adjusted frames, and such adjustments must therefore occur because keyword arguments are stored in their invocation frames. Renamed CheckClassContext to the more general CheckClass instruction. Made AdjustFrame operate on invocation frames again. Introduced explicit tests for class invocation since instantiators require an extra slot for each new instance. Fixed the "if" statement to employ conversion of expression results to boolean values. Split and improved test programs.
paul@233 1
#!/usr/bin/env python
paul@233 2
paul@233 3
import micropython.cmd
paul@233 4
import rsvp
paul@233 5
import sys
paul@233 6
import os
paul@233 7
from glob import glob
paul@233 8
paul@233 9
# Main program.
paul@233 10
paul@233 11
if __name__ == "__main__":
paul@233 12
    args = sys.argv[1:]
paul@233 13
    path = sys.path[:]
paul@233 14
    path.append("tests")
paul@233 15
paul@233 16
    # Process all tests.
paul@233 17
paul@233 18
    try:
paul@233 19
        _f = args.index("-f")
paul@233 20
        filenames = args[_f+1:]
paul@233 21
    except ValueError:
paul@233 22
        filenames = glob(os.path.join("tests", "*.py"))
paul@233 23
paul@233 24
    filenames.sort()
paul@233 25
paul@233 26
    results = []
paul@233 27
paul@233 28
    for filename in filenames:
paul@233 29
        print "Processing", filename
paul@233 30
paul@233 31
        try:
paul@233 32
            p = micropython.cmd.get_program(filename, path, args)
paul@233 33
            m = p.get_importer().get_module("__main__")
paul@233 34
paul@233 35
        # Report any errors.
paul@233 36
paul@233 37
        except micropython.ProcessingError, exc:
paul@233 38
            print repr(exc)
paul@233 39
            if "-tb" in args:
paul@233 40
                raise
paul@233 41
paul@233 42
        else:
paul@233 43
            rm = rsvp.machine(p)
paul@233 44
            success = rm.test(m)
paul@233 45
            print "Test successful?", success
paul@233 46
            results.append((filename, success))
paul@233 47
paul@233 48
    print
paul@233 49
    for result in results:
paul@233 50
        print result
paul@233 51
paul@233 52
# vim: tabstop=4 expandtab shiftwidth=4