Example #1
0
                context['program'] = extract
                context['user'] = user

                if user not in suites :
                    suites[user] = []
                
                suite = GraderSuite(context)
                suites[user].append(suite)
                for tc in ['.*\.ino', Comments, ArduinoBuilder] + pattern[1:] :
                    for name in unittest.defaultTestLoader.getTestCaseNames(tc) :
                        suite.addTest(tc(name, context))

    gradedir = sys.argv[1] + '-grades'
    if not os.path.isdir(gradedir) :
        os.makedirs(gradedir)
    for user in sorted(suites) : 
        print ("\n\n ****** Running test for user", user, " ******\n\n")
        runner(suites[user], os.path.join(gradedir, user + '.zip'))

    print ("\n\n===== done =====\n\n")

    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    fh = logging.FileHandler(os.path.join(gradedir, 'histogram.txt'))
    fh.setLevel(logging.DEBUG)
    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    logger.addHandler(fh)
    logger.addHandler(ch)
    histogram(logger)
Example #2
0
    exit (2)

os.environ['PYTHONPATH'] = ArduinoBuilder.installdir

context = {}
context['tempdir'] = tempfile.TemporaryDirectory().name
context['program'] = sketchfile
context['user'] = '******'

suite = [GraderSuite(context)]
loader = unittest.TestLoader()

print ("Searching for test modules...")
for e in os.listdir(ArduinoBuilder.testdir) :
    d = os.path.join(ArduinoBuilder.testdir,e)
    if os.path.isdir(d) : 
        f = os.path.join(d, '__init__.py')
        if os.path.isfile(f) :
            test = importlib.import_module("tests." + e)
            for pattern in test.files :
                m = re.search(pattern[0], ArduinoBuilder.clean_sketch(sketchfile))
                if m is not None :
                    for tc in ['.*\.ino', Comments, ArduinoBuilder] + pattern[1:] :
                        names = loader.getTestCaseNames(tc)
                        for name in names :
                            suite[0].addTest(tc(name, context))


runner(suite, 'run_log.zip')
histogram()