Exemplo n.º 1
0
    manifests = []
    for package_manifest in pubspec.PubspecYaml.recognize(location):
        manifests.append(package_manifest.to_dict())
    return manifests


def lock_tester(location,):
    manifests = []
    for package_manifest in pubspec.PubspecLock.recognize(location):
        manifests.append(package_manifest.to_dict())
    return manifests


build_tests(
    test_dir=os.path.join(test_data_dir, 'pubspec/specs'),
    clazz=TestPubspecDatadriven,
    test_method_prefix='test_pubspec_yaml',
    tested_function=pub_tester,
    test_file_suffix='pubspec.yaml',
    regen=False,
)

build_tests(
    test_dir=os.path.join(test_data_dir, 'pubspec/locks'),
    clazz=TestPubspecDatadriven,
    test_method_prefix='test_pubspec_lock',
    tested_function=lock_tester,
    test_file_suffix='pubspec.lock',
    regen=False,
)
Exemplo n.º 2
0
def tree_to_dict(o):
    if isinstance(o, pygmars.Token):
        return dict(label=o.label,
                    value=o.value,
                    start_line=o.start_line,
                    pos=o.pos)
    elif isinstance(o, pygmars.tree.Tree):
        return {o.label: [tree_to_dict(child) for child in o]}


build_tests(
    test_dir=os.path.join(test_data_dir, 'bashparse'),
    test_file_suffix='.sh',
    clazz=TestBashParserDatadriven,
    tested_function=lambda loc: list(
        bashparse.collect_shell_variables(loc, resolve=True)),
    test_method_prefix='test_collect_shell_variables_',
    regen=False,
)


class TestBashParser(PackageTester):
    test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

    def test_get_tokens(self):
        text = '''
# Contributor: Natanael Copa <*****@*****.**>
pkgname=gcc

pkgname="$pkgname$_target"
Exemplo n.º 3
0
        Return a list of token mappings by running the ``lexer`` on the ``text``
        string.
        """
        return [
            cls(*ts).to_dict() for ts in lexer().get_tokens_unprocessed(text)
        ]


class TestBashlexDatadriven(PackageTester):
    test_data_dir = test_data_dir


def lexer_tester(location, lexer_class):
    with open(location) as inp:
        text = inp.read()
    return PygmentsToken.lex(lexer_class, text)


build_tests(
    test_dir=os.path.join(test_data_dir, 'bashlex'),
    test_file_suffix=(
        '.sh',
        'APKBUILD',
        'PKGBUILD',
    ),
    clazz=TestBashlexDatadriven,
    tested_function=partial(lexer_tester, lexer_class=BashShellLexer),
    test_method_prefix='test_collect_shell_variables_',
    regen=False,
)
Exemplo n.º 4
0
        expected = test_installed + '-expected.json'
        check_result_equals_expected_json(result, expected, regen=REGEN_TEST_FIXTURES)


def apkbuild_tester(location):
    return alpine.parse_apkbuild(location, strict=True).to_dict()


class TestAlpineApkbuildDatadriven(PackageTester):
    test_data_dir = test_data_dir


build_tests(
    test_dir=os.path.join(test_data_dir, 'alpine/apkbuild'),
    clazz=TestAlpineApkbuildDatadriven,
    test_method_prefix='test_',
    tested_function=apkbuild_tester,
    test_file_suffix='APKBUILD',
    regen=REGEN_TEST_FIXTURES,
)


def apkbuild_problems_tester(location):
    return alpine.parse_apkbuild(location, strict=True).to_dict()


class TestAlpineApkbuildProblemsDatadriven(PackageTester):
    test_data_dir = test_data_dir


build_tests(
    test_dir=os.path.join(test_data_dir, 'alpine/apkbuild-problems'),