Ejemplo n.º 1
0
def test_all():
    cwd = Path(getcwd())
    all_omts = [p.as_posix() for p in cwd.glob('**/*.omt')]
    th = TallyHolder()
    if environ.get('TRAVIS'):
        if not environ.get('OMV_ENGINE'):
            tallies = [parse_omt(t) for t in all_omts]
        else:
            engine = environ.get('OMV_ENGINE').lower()
            tallies = [parse_omt(t)
                       for t in all_omts
                       if load_yaml(t)['engine'].lower() == engine]
    else:
        tallies = [parse_omt(t) for t in all_omts]
        
    for t in tallies:
        th.add(t)

    results = [t.all_passed() for t in tallies]
    inform('')
    inform("%i test(s) run" % len(tallies),
           overline='-', underline='-', center=True)
    inform('')
    if all(results):
        inform("All tests passing!", underline='=', center=True)
    else:
        failed = [trim_path(t.omt) for t in tallies if not t.all_passed()]
        inform("Some test(s) failed: ",  failed, underline='=')
    
    if is_verbose():
        print('\n'+th.summary()+'\n')

    assert all(results)
Ejemplo n.º 2
0
def test_one(omt_fname):
    tally = parse_omt(omt_fname)
    inform('')
    if tally.all_passed():
        inform("Test passed: %s" % omt_fname, overline='=',
               center=True)
    else:
        inform("Test failed: %s" % (omt_fname),
               underline='=', center=True)

    assert(tally.all_passed())
Ejemplo n.º 3
0
def test_one(omt_fname):
    tally = parse_omt(omt_fname)
    inform('')
    if tally.all_passed():
        inform("Test passed: %s" % omt_fname, overline='=', center=True)
    else:
        inform("Test failed: %s" % (omt_fname), underline='=', center=True)

    if is_verbose():
        th = TallyHolder()
        th.add(tally)
        print('\n' + th.summary() + '\n')

    assert (tally.all_passed())
def test_one(omt_fname):
    tally = parse_omt(omt_fname)
    inform('')
    if tally.all_passed():
        inform("Test passed: %s" % omt_fname, overline='=',
               center=True)
    else:
        inform("Test failed: %s" % (omt_fname),
               underline='=', center=True)
               
    if is_verbose():
        th = TallyHolder()
        th.add(tally)
        print('\n'+th.summary()+'\n')

    assert(tally.all_passed())
Ejemplo n.º 5
0
def parse_omt(omt_path):
    inform('')
    inform("Running tests defined in ", trim_path(omt_path),
           underline='=', center=False)
    
    mepomt = OMVTestParser(omt_path)
    if not OMVEngines.has_key(mepomt.engine):
        inform("Error! Unrecognised engine: %s"%mepomt.engine)
        exit(1)
    engine = OMVEngines[mepomt.engine](mepomt.modelpath)
    experiments = [exp for exp in mepomt.generate_exps(engine)]
    
    tally = Tallyman(mepomt)
    
    try:
        engine.run()
        for exp in experiments:
            inform('Running checks for experiment: ', exp.name, indent=1)
            inform('')
            results = exp.check_all()
            inform('{:<30}{:^20}'.format('Observable', 'Test Passed'),
                   underline='-', indent=3)
            for rn, rv in results.iteritems():
                inform(u'{:<30}{:^20}'.format(rn, check(rv)), indent=3)
            tally.add_experiment(exp, results)

    except (EngineInstallationError, EngineExecutionError):
        # TODO: serialize exception info
        inform('ERROR running engine ', engine.name, indent=1,
               underline='-', overline='-')

    return tally