micropython

test_all.py

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