예제 #1
0
def test_header_information(capsys):
    additional_options = {
        'rpmfile': [],
        'installed': ['python3-rpm'],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert 'packages: 1' in out
예제 #2
0
def test_run_single(capsys, packages):
    additional_options = {
        'rpmfile': [packages],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert 'E: no-signature' in out
    assert '1 packages and 0 specfiles checked' in out
    assert not err
예제 #3
0
def test_run_single(capsys, packages):
    additional_options = {
        'rpmfile': [packages],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert '1 packages and 0 specfiles checked' in out
    assert not err
예제 #4
0
def test_explain_unknown(capsys):
    message = 'bullcrap'
    additional_options = {
        'explain': message,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert 'Unknown message' in out
    assert not err
예제 #5
0
def test_configoutput(capsys):
    additional_options = {
        'print_config': True,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert out
    assert 'Vendor = "Fedora Project"' in out
    assert not err
예제 #6
0
def test_run_full_specs(capsys, packages):
    number_of_pkgs = len(packages)
    additional_options = {
        'rpmfile': packages,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert f'0 packages and {number_of_pkgs} specfiles checked' in out
    assert not err
예제 #7
0
파일: test_lint.py 프로젝트: marxin/rpmlint
def test_run_rpmlintrc_multiple(capsys, packages):
    additional_options = {
        'rpmfile': [packages],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert 'rpmlintrc:' not in out
    assert 'There are multiple items to be loaded for rpmlintrc' in err
    assert '0 badness' in out
예제 #8
0
def test_run_installed_and_no_files(capsys):
    additional_options = {
        'rpmfile': [],
        'installed': ['python3-rpm'],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert '1 packages and 0 specfiles checked' in out
    assert not err
예제 #9
0
def test_explain_known(capsys):
    message = ['infopage-not-compressed']
    additional_options = {
        'explain': message,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert 'This info page is not compressed' in out
    assert 'Unknown message' not in out
    assert not err
예제 #10
0
def test_run_installed(capsys, packages):
    # load up 1 normal path file and 2 installed packages
    additional_options = {
        'rpmfile': [packages],
        'installed': ['python3-rpm', 'rpm'],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert '3 packages and 0 specfiles checked' in out
    assert not err
예제 #11
0
def test_run_installed_not_present(capsys):
    additional_options = {
        'rpmfile': [],
        'installed': ['non-existing-package'],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert '0 packages and 0 specfiles checked' in out
    assert 'there is no installed rpm' in err
    assert 'There are no files to process' in err
예제 #12
0
def test_run_strict(capsys, packages):
    """
    Test if we convert warning to error
    """
    additional_options = {
        'rpmfile': [packages],
        'strict': True,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.checks = _remove_except_zip(linter.checks)
    linter.run()
    out, err = capsys.readouterr()
    assert 'W: unable-to-read-zip' not in out
    assert 'E: unable-to-read-zip' in out
    assert not err
예제 #13
0
def lint():
    """
    Main wrapper for lint command processing
    """
    options = process_lint_args(sys.argv[1:])
    lint = Lint(options)
    sys.exit(lint.run())
예제 #14
0
def test_run_full_directory(capsys, packages):
    assert packages.is_dir()
    file_list = []
    for item in packages.iterdir():
        if item.is_file():
            file_list.append(item)
    number_of_pkgs = len(file_list)
    additional_options = {
        'rpmfile': [packages],
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert f'0 packages and {number_of_pkgs} specfiles checked' in out
    assert not err
예제 #15
0
def test_run_full_rpm(capsys, packages):
    number_of_pkgs = len(packages)
    additional_options = {
        'rpmfile': packages,
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()
    assert f'{number_of_pkgs} packages and 0 specfiles checked' in out
    # we convert the err as we don't care about errors from missing
    # spellchecking dictionaries -> we have to ignore it
    err_reduced = [a for a in err.split('\n') if not a.startswith('(none): W: unable to load spellchecking dictionary for') and a != '']
    # also we can find out signatures are wrong because of the other distros
    # could've signed it
    err_reduced = [a for a in err_reduced if not a.startswith('Error checking signature of')]
    assert not err_reduced
예제 #16
0
def test_installed_package(capsys):
    additional_options = {'installed': ['bzip2'], 'permissive': True}
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    retcode = linter.run()
    out, err = capsys.readouterr()
    assert '1 packages and 0 specfiles checked' in out
    assert retcode == 0
예제 #17
0
파일: test_lint.py 프로젝트: xsuchy/rpmlint
def test_explain_no_binary_from_cfg(capsys):
    """
    Test that 'explain' option can read updated description from configuration.

    Test 'no-binary' error that is defined in CheckBinaries.toml file by
    default and then it's overridden to the custom values defined in
    'descriptions.config' file.
    """
    additional_options = {
        'config': [testpath() / 'configs/descriptions.config'],
        'explain': ['no-binary']
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()

    # the new string is present and the old one is not
    assert 'A new text for no-binary error.' in out
    assert 'The package should be of the noarch architecture' not in out
    assert not err
예제 #18
0
파일: test_lint.py 프로젝트: xsuchy/rpmlint
def test_explain_non_standard_dir_from_cfg(capsys):
    """
    Test that 'explain' option can read updated description from configuration.

    Test 'non-standard-dir-in-usr' error that is special because the original
    description is not defined in FHSCheck.toml but in FHSCheck.py. Then it's
    supposed to be overridden to the custom values defined in
    'descriptions.config' file.
    """
    additional_options = {
        'config': [testpath() / 'configs/descriptions.config'],
        'explain': ['non-standard-dir-in-usr']
    }
    options = {**options_preset, **additional_options}
    linter = Lint(options)
    linter.run()
    out, err = capsys.readouterr()

    assert 'A new text for non-standard-dir-in-usr error.' in out
    assert 'Your package is creating a non-standard subdirectory in /usr' not in out
    assert not err
예제 #19
0
def test_run_empty(capsys):
    linter = Lint(options_preset)
    linter.run()
    out, err = capsys.readouterr()
    assert err
    assert '0 packages and 0 specfiles checked; 0 errors, 0 warnings' in out