diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:34 +0000 |
commit | 83dcb1205fee22e9683a0de5f963e1225e24b4ef (patch) | |
tree | 205d12aae7e8d5f5ebf91f87803a61d49b21508d /tests | |
parent | Releasing progress-linux version 0.1.40-0.0~progress7.99u1. (diff) | |
download | debputy-83dcb1205fee22e9683a0de5f963e1225e24b4ef.tar.xz debputy-83dcb1205fee22e9683a0de5f963e1225e24b4ef.zip |
Merging upstream version 0.1.41.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lint_tests/test_lint_dctrl.py | 131 |
1 files changed, 125 insertions, 6 deletions
diff --git a/tests/lint_tests/test_lint_dctrl.py b/tests/lint_tests/test_lint_dctrl.py index 745c323..840fabe 100644 --- a/tests/lint_tests/test_lint_dctrl.py +++ b/tests/lint_tests/test_lint_dctrl.py @@ -732,7 +732,12 @@ def test_dctrl_lint_ambiguous_pkgfile(line_linter: LintWrapper) -> None: # FIXME: This relies on "cwd" being a valid debian directory using debhelper. Fix and # remove the `build_time_only` restriction - line_linter.source_root = build_virtual_file_system(["./debian/bar.install"]) + line_linter.source_root = build_virtual_file_system( + [ + virtual_path_def(".", fs_path="."), + "./debian/bar.service", + ] + ) diagnostics = line_linter(lines) print(diagnostics) @@ -740,8 +745,8 @@ def test_dctrl_lint_ambiguous_pkgfile(line_linter: LintWrapper) -> None: issue = diagnostics[0] msg = ( - 'Possible typo in "./debian/bar.install". Consider renaming the file to "debian/foo.bar.install"' - ' or "debian/foo.install if it is intended for foo' + 'Possible typo in "./debian/bar.service". Consider renaming the file to "debian/foo.service"' + ' (or maybe "debian/foo.bar.service") if it is intended for foo' ) assert issue.message == msg assert f"{issue.range}" == "7:0-8:0" @@ -749,8 +754,59 @@ def test_dctrl_lint_ambiguous_pkgfile(line_linter: LintWrapper) -> None: diag_data = issue.data assert isinstance(diag_data, dict) assert diag_data.get("report_for_related_file") in ( - "./debian/bar.install", - "debian/bar.install", + "./debian/bar.service", + "debian/bar.service", + ) + + +@build_time_only +def test_dctrl_lint_ambiguous_pkgfile_no_name_segment(line_linter: LintWrapper) -> None: + lines = textwrap.dedent( + f"""\ + Source: foo + Section: devel + Priority: optional + Standards-Version: {CURRENT_STANDARDS_VERSION} + Maintainer: Jane Developer <jane@example.com> + Build-Depends: debhelper-compat (= 13), dh-sequence-zz-debputy, + + Package: foo + Architecture: all + Depends: bar, baz + Description: some short synopsis + A very interesting description + with a valid synopsis + . + Just so be clear, this is for a test. + """ + ).splitlines(keepends=True) + + # FIXME: This relies on "cwd" being a valid debian directory using debhelper. Fix and + # remove the `build_time_only` restriction + line_linter.source_root = build_virtual_file_system( + [ + virtual_path_def(".", fs_path="."), + "./debian/bar.alternatives", + ] + ) + + diagnostics = line_linter(lines) + print(diagnostics) + assert diagnostics and len(diagnostics) == 1 + issue = diagnostics[0] + + msg = ( + 'Possible typo in "./debian/bar.alternatives". Consider renaming the file to "debian/foo.alternatives"' + " if it is intended for foo" + ) + assert issue.message == msg + assert f"{issue.range}" == "7:0-8:0" + assert issue.severity == DiagnosticSeverity.Warning + diag_data = issue.data + assert isinstance(diag_data, dict) + assert diag_data.get("report_for_related_file") in ( + "./debian/bar.alternatives", + "debian/bar.alternatives", ) @@ -779,7 +835,12 @@ def test_dctrl_lint_stem_typo_pkgfile(line_linter: LintWrapper) -> None: # FIXME: This relies on "cwd" being a valid debian directory using debhelper. Fix and # remove the `build_time_only` restriction - line_linter.source_root = build_virtual_file_system(["./debian/foo.intsall"]) + line_linter.source_root = build_virtual_file_system( + [ + virtual_path_def(".", fs_path="."), + "./debian/foo.intsall", + ] + ) diagnostics = line_linter(lines) print(diagnostics) @@ -827,6 +888,7 @@ def test_dctrl_lint_stem_inactive_pkgfile_fp(line_linter: LintWrapper) -> None: # load the `zz-debputy` sequence. line_linter.source_root = build_virtual_file_system( [ + virtual_path_def(".", fs_path="."), "./debian/foo.install", virtual_path_def( "./debian/rules", @@ -846,3 +908,60 @@ def test_dctrl_lint_stem_inactive_pkgfile_fp(line_linter: LintWrapper) -> None: print(diagnostics) # We should not emit diagnostics when the package is not using dh! assert not diagnostics + + +@requires_levenshtein +@build_time_only +def test_dctrl_lint_stem_typo_pkgfile_ignored_exts_or_files( + line_linter: LintWrapper, +) -> None: + lines = textwrap.dedent( + f"""\ + Source: foo + Section: devel + Priority: optional + Standards-Version: {CURRENT_STANDARDS_VERSION} + Maintainer: Jane Developer <jane@example.com> + Build-Depends: debhelper-compat (= 13) + + Package: foo + Architecture: all + Depends: bar, baz + Description: some short synopsis + A very interesting description + with a valid synopsis + . + Just so be clear, this is for a test. + """ + ).splitlines(keepends=True) + + # FIXME: This relies on "cwd" being a valid debian directory using debhelper. Fix and + # remove the `build_time_only` restriction + line_linter.source_root = build_virtual_file_system( + [ + virtual_path_def(".", fs_path="."), + "debian/salsa-ci.yml", + "debian/gbp.conf", + "debian/foo.conf", + "debian/foo.sh", + "debian/foo.yml", + # One wrong one to ensure the test works. + "debian/foo.intsall", + ] + ) + + diagnostics = line_linter(lines) + print(diagnostics) + assert diagnostics and len(diagnostics) == 1 + issue = diagnostics[0] + + msg = 'The file "./debian/foo.intsall" is likely a typo of "./debian/foo.install"' + assert issue.message == msg + assert f"{issue.range}" == "7:0-8:0" + assert issue.severity == DiagnosticSeverity.Warning + diag_data = issue.data + assert isinstance(diag_data, dict) + assert diag_data.get("report_for_related_file") in ( + "./debian/foo.intsall", + "debian/foo.intsall", + ) |