Beispiel #1
0
def check_loc():
    veil_component.load_all_components()
    component_files = {}
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            module_loc = get_loc(module_file)
            component_files.setdefault(component_name, []).append(
                (module_file, module_loc))
    max_loc = 0
    application = get_application()
    ignored_app_components = getattr(application,
                                     'LOC_CHECK_IGNORED_COMPONENTS', set())
    ignored_app_component_prefixes = getattr(
        application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set())
    for component_name in sorted(component_files):
        files = component_files[component_name]
        component_loc = sum(f[1] for f in files)
        if component_name not in WHITE_LIST and component_name not in ignored_app_components and all(
                not component_name.startswith(prefix)
                for prefix in ignored_app_component_prefixes):
            max_loc = max(component_loc, max_loc)
            if component_loc > THRESHOLD:
                raise Exception(
                    '{} contains {} lines of code, extract component out!\n{}'.
                    format(component_name, component_loc,
                           '\n'.join(unicode(f) for f in files)))
    if THRESHOLD > GOAL and THRESHOLD - max_loc > 50:
        raise Exception('Threshold can be reduced to {} now', max_loc)
Beispiel #2
0
def update_dynamic_dependencies():
    if not is_recording_dynamic_dependencies():
        LOGGER.warn('cannot update dynamic dependencies because the recording is not started yet')
        return
    try:
        load_all_components() # import module will execute a lot record_dynamic_dependency_provider
    except Exception:
        pass
Beispiel #3
0
def update_dynamic_dependencies():
    if not is_recording_dynamic_dependencies():
        LOGGER.warn(
            'cannot update dynamic dependencies because the recording is not started yet'
        )
        return
    try:
        load_all_components(
        )  # import module will execute a lot record_dynamic_dependency_provider
    except Exception:
        pass
Beispiel #4
0
def check_correctness():
    package_names = ['veil']
    all_components = load_all_components(
    )  # load all so sys.modules contains module to be tested
    for component_name in all_components:
        package_names.append(component_name)
    test_package(*package_names)
Beispiel #5
0
def check_loc():
    veil_component.load_all_components()
    component_files = {}
    for module_name, module in sys.modules.items():
        component_name = veil_component.get_leaf_component(module_name)
        if component_name and hasattr(module, '__file__'):
            module_file = module.__file__.replace('.pyc', '.py')
            module_loc = get_loc(module_file)
            component_files.setdefault(component_name, []).append((module_file, module_loc))
    max_loc = 0
    application = get_application()
    ignored_app_components = getattr(application, 'LOC_CHECK_IGNORED_COMPONENTS', set())
    ignored_app_component_prefixes = getattr(application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set())
    for component_name in sorted(component_files):
        files = component_files[component_name]
        component_loc = sum(f[1] for f in files)
        if component_name not in WHITE_LIST and component_name not in ignored_app_components and all(
                not component_name.startswith(prefix) for prefix in ignored_app_component_prefixes):
            max_loc = max(component_loc, max_loc)
            if component_loc > THRESHOLD:
                raise Exception('{} contains {} lines of code, extract component out!\n{}'.format(
                    component_name, component_loc, '\n'.join(unicode(f) for f in files)))
    if THRESHOLD > GOAL and THRESHOLD - max_loc > 50:
        raise Exception('Threshold can be reduced to {} now', max_loc)
Beispiel #6
0
def execute_document_statement(statement_name, *args):
    if not get_executing_test(optional=True):
        load_all_components()
        set_up_fake_test()
        atexit.register(tear_down_fake_test)
    return contexts[-1](statement_name, args)
Beispiel #7
0
def execute_document_statement(statement_name, *args):
    if not get_executing_test(optional=True):
        load_all_components()
        set_up_fake_test()
        atexit.register(tear_down_fake_test)
    return contexts[-1](statement_name, args)
Beispiel #8
0
def check_correctness():
    package_names = ['veil']
    all_components = load_all_components() # load all so sys.modules contains module to be tested
    for component_name in all_components:
        package_names.append(component_name)
    test_package(*package_names)