micropython

Annotated test_all.py

515:20ea2e9b841d
2012-06-03 Paul Boddie Restricted attribute assignments observed through usage analysis to instance attributes only.
paul@233 1
#!/usr/bin/env python
paul@233 2
paul@233 3
import sys
paul@233 4
import os
paul@233 5
from glob import glob
paul@317 6
import operator
paul@233 7
paul@352 8
libdirs = [
paul@352 9
    os.path.join(os.path.split(__file__)[0], "lib"),
paul@352 10
    "/usr/share/micropython/lib"
paul@352 11
    ]
paul@352 12
paul@233 13
# Main program.
paul@233 14
paul@233 15
if __name__ == "__main__":
paul@233 16
    args = sys.argv[1:]
paul@352 17
    path = libdirs + sys.path[:]
paul@233 18
    path.append("tests")
paul@233 19
paul@233 20
    # Process all tests.
paul@233 21
paul@233 22
    try:
paul@233 23
        _f = args.index("-f")
paul@233 24
        filenames = args[_f+1:]
paul@407 25
        args = args[:_f]
paul@233 26
    except ValueError:
paul@233 27
        filenames = glob(os.path.join("tests", "*.py"))
paul@233 28
paul@233 29
    filenames.sort()
paul@233 30
paul@407 31
    # Make some arguments for the test program.
paul@407 32
paul@407 33
    args.append("-t")
paul@407 34
    if "-tb" not in args:
paul@407 35
        args.append("-exit")
paul@407 36
paul@233 37
    results = []
paul@233 38
paul@233 39
    for filename in filenames:
paul@233 40
        print "Processing", filename
paul@441 41
        status = os.system("%s test.py %s %s" % (sys.executable, filename, " ".join(args)))
paul@441 42
        if status == 2:
paul@441 43
            print "Interrupted!"
paul@441 44
            break
paul@441 45
paul@441 46
        success = status == 0
paul@407 47
        print "Test successful?", success and "Yes" or "No"
paul@407 48
        results.append((filename, success))
paul@233 49
paul@362 50
    failed = [result[0] for result in results if not result[1]]
paul@362 51
    if failed:
paul@362 52
        print
paul@362 53
        print "Failed tests:"
paul@362 54
        for filename in failed:
paul@362 55
            print filename
paul@317 56
paul@317 57
    print
paul@317 58
    print "All successful?"
paul@317 59
    print reduce(operator.and_, [x[1] for x in results], 1) and "Yes" or "No"
paul@233 60
paul@233 61
# vim: tabstop=4 expandtab shiftwidth=4