summaryrefslogtreecommitdiffstats
path: root/tests/lint_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lint_tests')
-rw-r--r--tests/lint_tests/conftest.py1
-rw-r--r--tests/lint_tests/lint_tutil.py6
-rw-r--r--tests/lint_tests/test_lint_dctrl.py58
3 files changed, 54 insertions, 11 deletions
diff --git a/tests/lint_tests/conftest.py b/tests/lint_tests/conftest.py
index 2c54eb7..bf4b3b0 100644
--- a/tests/lint_tests/conftest.py
+++ b/tests/lint_tests/conftest.py
@@ -3,6 +3,7 @@ from debian.debian_support import DpkgArchTable
from debputy._deb_options_profiles import DebBuildOptionsAndProfiles
from debputy.architecture_support import DpkgArchitectureBuildProcessValuesTable
+from debputy.lsp.style_prefs import StylePreferenceTable
from debputy.packages import DctrlParser
from debputy.util import setup_logging
diff --git a/tests/lint_tests/lint_tutil.py b/tests/lint_tests/lint_tutil.py
index 83b69fd..8290712 100644
--- a/tests/lint_tests/lint_tutil.py
+++ b/tests/lint_tests/lint_tutil.py
@@ -9,6 +9,7 @@ from debputy.linting.lint_util import (
LintStateImpl,
LintState,
)
+from debputy.lsp.style_prefs import StylePreferenceTable, EffectivePreference
from debputy.packages import DctrlParser
from debputy.plugin.api.feature_set import PluginProvidedFeatureSet
@@ -43,6 +44,8 @@ class LintWrapper:
self.dctrl_lines: Optional[List[str]] = None
self.path = path
self._dctrl_parser = dctrl_parser
+ self.lint_style_preference_table = StylePreferenceTable({}, {})
+ self.effective_preference: Optional[EffectivePreference] = None
def __call__(self, lines: List[str]) -> Optional[List["Diagnostic"]]:
source_package = None
@@ -56,10 +59,13 @@ class LintWrapper:
)
state = LintStateImpl(
self._debputy_plugin_feature_set,
+ self.lint_style_preference_table,
self.path,
+ "".join(dctrl_lines) if dctrl_lines is not None else "",
lines,
source_package,
binary_packages,
+ self.effective_preference,
)
return check_diagnostics(self._handler(state))
diff --git a/tests/lint_tests/test_lint_dctrl.py b/tests/lint_tests/test_lint_dctrl.py
index ce34d7c..bcb1613 100644
--- a/tests/lint_tests/test_lint_dctrl.py
+++ b/tests/lint_tests/test_lint_dctrl.py
@@ -18,6 +18,9 @@ except ImportError:
pass
+STANDARDS_VERSION = "4.7.0"
+
+
class DctrlLintWrapper(LintWrapper):
def __call__(self, lines: List[str]) -> Optional[List["Diagnostic"]]:
@@ -93,15 +96,15 @@ def test_dctrl_lint(line_linter: LintWrapper) -> None:
msg = 'The value "base" is not supported in Section.'
assert second_warn.message == msg
- assert f"{second_warn.range}" == "8:9-8:13"
+ assert f"{second_warn.range}" == "7:9-7:13"
@requires_levenshtein
def test_dctrl_lint_typos(line_linter: LintWrapper) -> None:
lines = textwrap.dedent(
- """\
+ f"""\
Source: foo
- Standards-Version: 4.5.2
+ Standards-Version: {STANDARDS_VERSION}
Priority: optional
Section: devel
Maintainer: Jane Developer <jane@example.com>
@@ -132,9 +135,9 @@ def test_dctrl_lint_typos(line_linter: LintWrapper) -> None:
@requires_levenshtein
def test_dctrl_lint_mx_value_with_typo(line_linter: LintWrapper) -> None:
lines = textwrap.dedent(
- """\
+ f"""\
Source: foo
- Standards-Version: 4.5.2
+ Standards-Version: {STANDARDS_VERSION}
Priority: optional
Section: devel
Maintainer: Jane Developer <jane@example.com>
@@ -165,15 +168,15 @@ def test_dctrl_lint_mx_value_with_typo(line_linter: LintWrapper) -> None:
typo_msg = 'It is possible that the value is a typo of "all".'
assert mx_diag.message == mx_msg
assert typo_diag.message == typo_msg
- assert f"{mx_diag.range}" == "10:24-10:28"
- assert f"{typo_diag.range}" == "10:24-10:28"
+ assert f"{mx_diag.range}" == "9:24-9:28"
+ assert f"{typo_diag.range}" == "9:24-9:28"
def test_dctrl_lint_mx_value(line_linter: LintWrapper) -> None:
lines = textwrap.dedent(
- """\
+ f"""\
Source: foo
- Standards-Version: 4.5.2
+ Standards-Version: {STANDARDS_VERSION}
Priority: optional
Section: devel
Maintainer: Jane Developer <jane@example.com>
@@ -200,9 +203,9 @@ def test_dctrl_lint_mx_value(line_linter: LintWrapper) -> None:
assert f"{diag.range}" == "8:14-8:17"
lines = textwrap.dedent(
- """\
+ f"""\
Source: foo
- Standards-Version: 4.5.2
+ Standards-Version: {STANDARDS_VERSION}
Priority: optional
Section: devel
Maintainer: Jane Developer <jane@example.com>
@@ -227,3 +230,36 @@ def test_dctrl_lint_mx_value(line_linter: LintWrapper) -> None:
assert diag.message == msg
assert diag.severity == DiagnosticSeverity.Error
assert f"{diag.range}" == "8:24-8:27"
+
+
+def test_dctrl_lint_dup_sep(line_linter: LintWrapper) -> None:
+ lines = textwrap.dedent(
+ f"""\
+ Source: foo
+ Section: devel
+ Priority: optional
+ Standards-Version: {STANDARDS_VERSION}
+ Maintainer: Jane Developer <jane@example.com>
+ Build-Depends: debhelper-compat (= 13)
+
+ Package: foo
+ Architecture: all
+ Depends: foo,
+ , bar
+ Description: Some very interesting synopsis
+ A very interesting description
+ that spans multiple lines
+ .
+ Just so be clear, this is for a test.
+ """
+ ).splitlines(keepends=True)
+
+ diagnostics = line_linter(lines)
+ print(diagnostics)
+ assert diagnostics and len(diagnostics) == 1
+ error = diagnostics[0]
+
+ msg = "Duplicate separator"
+ assert error.message == msg
+ assert f"{error.range}" == "10:1-10:2"
+ assert error.severity == DiagnosticSeverity.Error