1 #!/usr/bin/env python 2 3 import micropython.cmd 4 import rsvp 5 import sys 6 import os 7 from glob import glob 8 9 # Main program. 10 11 if __name__ == "__main__": 12 args = sys.argv[1:] 13 path = sys.path[:] 14 path.append("tests") 15 16 # Process all tests. 17 18 try: 19 _f = args.index("-f") 20 filenames = args[_f+1:] 21 except ValueError: 22 filenames = glob(os.path.join("tests", "*.py")) 23 24 filenames.sort() 25 26 results = [] 27 28 for filename in filenames: 29 print "Processing", filename 30 31 try: 32 p = micropython.cmd.get_program(filename, path, args) 33 m = p.get_importer().get_module("__main__") 34 35 # Report any errors. 36 37 except micropython.ProcessingError, exc: 38 print repr(exc) 39 if "-tb" in args: 40 raise 41 42 else: 43 rm = rsvp.machine(p) 44 success = rm.test(m) 45 print "Test successful?", success 46 results.append((filename, success)) 47 48 print 49 for result in results: 50 print result 51 52 # vim: tabstop=4 expandtab shiftwidth=4