Example #1
0
def mcdplib_test_setup_posets(context, libname):
    """ 
        Loads all mcdp_lang_tests that were specified by comptests
        using the for_all_nameddps decorator. 
    """
    from mcdp_tests import load_tests_modules

    l = get_test_library(libname)

    posets = l.list_posets()

    from mcdp_tests.generation import for_all_posets
    load_tests_modules()
    registered = for_all_posets.registered

    print('Found posets: %r' % posets)
    print('Found registered: %r' % registered)

    for id_poset in posets:
        c = context.child(id_poset)

        ndp = c.comp(_load_poset, libname, id_poset, job_id='load')

        for ftest in registered:
            c.comp(ftest, id_poset, ndp)
Example #2
0
def mcdplib_test_setup_nameddps(context, libname):
    """ 
        Loads all mcdp_lang_tests that were specified by comptests
        using the for_all_nameddps decorator. 
    """
    from mcdp_tests import load_tests_modules
    l = get_test_library(libname)
    models = l.get_models()

    from mcdp_tests.generation import for_all_nameddps, for_all_nameddps_dyn
    load_tests_modules()

    print('Found models: %r' % models)
    print('Found registered in for_all_nameddps_dyn: %r' % 
          for_all_nameddps.registered)
    print('Found registered in for_all_nameddps: %r' % 
          for_all_nameddps_dyn.registered)

    for model_name in models:
        f = l._get_file_data(model_name + '.' + MCDPLibrary.ext_ndps)

        source = f['data']

        if gives_syntax_error(source):
            print('Skipping because syntax error')
            # TODO: actually check syntax error
        else:
            c = context.child(model_name, extra_report_keys=dict(id_ndp=model_name))

            if gives_not_implemented_error(source):
                c.comp(mcdplib_assert_not_implemented_error_fn, libname, model_name,
                       job_id='assert_not_implemented_error')
            elif gives_semantic_error(source):
                c.comp(mcdplib_assert_semantic_error_fn, libname, model_name,
                       job_id='assert_semantic_error')
            else:
                ndp = c.comp(_load_ndp, libname, model_name, job_id='load')

                    
                for ftest in for_all_nameddps.registered:
                    
                    if accepts_arg(ftest, 'libname'):
                        print('using libname for %s' % ftest)
                        c.comp(ftest, model_name, ndp, libname=libname,
                               job_id=ftest.__name__)
                    else:
                        c.comp(ftest, model_name, ndp)
                        
                for ftest in for_all_nameddps_dyn.registered:
                    
                    if accepts_arg(ftest, 'libname'):
                        print('using libname for %s' % ftest)
                        c.comp_dynamic(ftest, model_name, ndp, libname=libname,
                                       job_id=ftest.__name__)
                    else:
                        c.comp_dynamic(ftest, model_name, ndp)
Example #3
0
def mcdplib_test_setup_sources(context, libname):
    from mcdp_tests import load_tests_modules

    l = get_test_library(libname)

    load_tests_modules()

    types = [
        (['mcdp', 'mcdp_template', 'mcdp_poset',
          'mcdp_value'], for_all_source_all),
        (['mcdp'], for_all_source_mcdp),
        (['mcdp_template'], for_all_source_mcdp_template),
        (['mcdp_poset'], for_all_source_mcdp_poset),
        (['mcdp_value'], for_all_source_mcdp_value),
    ]
    for extensions, accumulator in types:
        mcdplib_test_setup_sources_(context, libname, l, extensions,
                                    accumulator)
Example #4
0
def mcdplib_test_setup_template(context, libname):
    from mcdp_tests import load_tests_modules
    l = get_test_library(libname)
    templates = l.list_templates()

    from mcdp_tests.generation import for_all_templates
    load_tests_modules()
    registered = for_all_templates.registered

    print('Found: %r' % templates)
    print('Registered: %r' % registered)

    for id_template in templates:
        c = context.child(id_template)

        ndp = c.comp(_load_template, libname, id_template, job_id='load')

        for ftest in registered:
            c.comp(ftest, id_template, ndp)
Example #5
0
def mcdplib_test_setup_primitivedps(context, libname):
    from mcdp_tests import load_tests_modules
    l = get_test_library(libname)
    dps = l.list_primitivedps()

    from mcdp_tests.generation import for_all_dps
    load_tests_modules()
    registered = for_all_dps.registered

    print('Found: %r' % dps)
    print('Registered: %r' % registered)

    for id_dp in dps:
        c = context.child(id_dp)

        ndp = c.comp(_load_primitivedp, libname, id_dp, job_id='load')

        for ftest in registered:
            c.comp(ftest, id_dp, ndp)
Example #6
0
def mcdplib_test_setup_source_mcdp(context, libname):
    from mcdp_tests import load_tests_modules

    l = get_test_library(libname)

    load_tests_modules()

    registered = for_all_source_mcdp.registered

    print('Found registered: %r' % registered)

    for basename in l.file_to_contents:
        _model_name, ext = os.path.splitext(basename)
        if ext != ".mcdp":
            # print basename, ext
            continue

        f = l._get_file_data(basename)
#         if not belongs_to_lib(f['realpath'], mcdplib):
#             continue

        source = f['data']
        filename = f['realpath']

        if gives_syntax_error(source):
            print('Skipping because syntax error')
            # TODO: actually check syntax error
        elif gives_semantic_error(source):
            print('Skipping because semantic error')

        else:            

            c = context.child(basename)
    
            for ftest in registered:
                c.comp(ftest, filename, source)
Example #7
0
def mcdplib_test_setup_spec(context, spec_name, libname):
    """ 
        Loads all mcdp_lang_tests that were specified by comptests
        using the for_all_nameddps decorator. 
    """
    from mcdp_tests import load_tests_modules
    l = get_test_library(libname)
    things = l.list_spec(spec_name)

    from mcdp_tests.generation import test_accumulators, R, D

    regular = test_accumulators[spec_name][R]
    dynamic = test_accumulators[spec_name][D]

    load_tests_modules()

    if False:
        print('Found models: %r' % things)
        print('Found registered: %r' % regular.registered)
        print('Found registered: %r' % dynamic.registered)

    extension = specs[spec_name].extension

    for thing_name in things:
        f = l._get_file_data(thing_name + '.' + extension)

        source = f['data']

        if gives_syntax_error(source):
            print('Skipping because syntax error')
            # TODO: actually check syntax error
            pass
        else:
            extra_report_keys = dict(spec_name=spec_name,
                                     thing_name=thing_name)
            c = context.child(thing_name, extra_report_keys=extra_report_keys)

            if gives_not_implemented_error(source):
                c.comp(mcdplib_assert_not_implemented_error_fn,
                       libname,
                       thing_name,
                       job_id='assert_not_implemented_error')
            elif gives_semantic_error(source):
                c.comp(mcdplib_assert_semantic_error_fn,
                       libname,
                       thing_name,
                       job_id='assert_semantic_error')
            else:
                thing = c.comp(_load_spec,
                               libname,
                               spec_name,
                               thing_name,
                               job_id='load')

                for ftest in regular.registered:

                    if accepts_arg(ftest, 'libname'):
                        # print('using libname for %s' % ftest)
                        c.comp(ftest,
                               thing_name,
                               thing,
                               libname=libname,
                               job_id=ftest.__name__)
                    else:
                        c.comp(ftest, thing_name, thing)

                for ftest in dynamic.registered:

                    if accepts_arg(ftest, 'libname'):
                        # print('using libname for %s' % ftest)
                        c.comp_dynamic(ftest,
                                       thing_name,
                                       thing,
                                       libname=libname,
                                       job_id=ftest.__name__)
                    else:
                        c.comp_dynamic(ftest, thing_name, thing)