Ejemplo n.º 1
0
def before_request():
    g.config = parse_standard_config_files()
    g.db = DB(g.config['db']['conn_url'])

    # Template settings.
    app.jinja_env.lstrip_blocks = True
    app.jinja_env.trim_blocks = True

    # Filters.
    app.jinja_env.filters['age'] = format_age
    app.jinja_env.filters['date'] = format_date
    app.jinja_env.filters['id'] = format_id
    app.jinja_env.filters['runtime'] = format_runtime
    app.jinja_env.filters['nl2br'] = nl2br
    def setUp(self):
        self.app = app.test_client()

        # Patch parse_standard_config_files() to allow config customization.
        parse_config_patcher = mock.patch(
            'regression_tests.web.views.parse_standard_config_files')
        self.addCleanup(parse_config_patcher.stop)
        self.mock_parse_standard_config_files = parse_config_patcher.start()
        # Do not parse the local configuration file to ensure that the tests
        # are run with the same settings, disregarding overrides in the local
        # configuration file.
        self.config = parse_standard_config_files(include_local=False)
        self.mock_parse_standard_config_files.return_value = self.config

        # Customize the config by overriding the needed global settings.
        # Use the SQLite :memory: database.
        self.config['db']['conn_url'] = 'sqlite://'
"""

import argparse

from regression_tests.clang import setup_clang_bindings
from regression_tests.config import parse_standard_config_files
from regression_tests.parsers.c_parser import parse_file


def parse_args():
    """Parses command-line arguments and returns them."""
    parser = argparse.ArgumentParser(description='Parser of C files.')
    parser.add_argument('FILE',
                        help=('Path to a file with C code to be parsed.'))
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help=('Print also dumps of functions.'))
    args = parser.parse_args()

    return args


args = parse_args()
config = parse_standard_config_files()
setup_clang_bindings(config['runner']['clang_dir'])
module = parse_file(args.FILE, print_errors=True)
if module.has_parse_errors():
    print()
module.dump(args.verbose)