summaryrefslogtreecommitdiff
path: root/test/sanity/code-smell
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanity/code-smell')
-rw-r--r--test/sanity/code-smell/ansible-requirements.py1
-rw-r--r--test/sanity/code-smell/deprecated-config.requirements.in2
-rw-r--r--test/sanity/code-smell/deprecated-config.requirements.txt6
-rw-r--r--test/sanity/code-smell/obsolete-files.json2
-rw-r--r--test/sanity/code-smell/package-data.requirements.in8
-rw-r--r--test/sanity/code-smell/package-data.requirements.txt25
-rw-r--r--test/sanity/code-smell/pymarkdown.config.json11
-rw-r--r--test/sanity/code-smell/pymarkdown.json7
-rw-r--r--test/sanity/code-smell/pymarkdown.py64
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.in1
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.txt9
-rw-r--r--test/sanity/code-smell/release-names.py7
-rw-r--r--test/sanity/code-smell/release-names.requirements.in1
-rw-r--r--test/sanity/code-smell/release-names.requirements.txt4
-rw-r--r--test/sanity/code-smell/test-constraints.py6
-rw-r--r--test/sanity/code-smell/update-bundled.requirements.txt3
16 files changed, 40 insertions, 117 deletions
diff --git a/test/sanity/code-smell/ansible-requirements.py b/test/sanity/code-smell/ansible-requirements.py
index 25d4ec88..4d1a652f 100644
--- a/test/sanity/code-smell/ansible-requirements.py
+++ b/test/sanity/code-smell/ansible-requirements.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import re
+import sys
def read_file(path):
diff --git a/test/sanity/code-smell/deprecated-config.requirements.in b/test/sanity/code-smell/deprecated-config.requirements.in
index 4e859bb8..859c4ee7 100644
--- a/test/sanity/code-smell/deprecated-config.requirements.in
+++ b/test/sanity/code-smell/deprecated-config.requirements.in
@@ -1,2 +1,2 @@
-jinja2
+jinja2 # ansible-core requirement
pyyaml
diff --git a/test/sanity/code-smell/deprecated-config.requirements.txt b/test/sanity/code-smell/deprecated-config.requirements.txt
index ae96cdf4..338e3f38 100644
--- a/test/sanity/code-smell/deprecated-config.requirements.txt
+++ b/test/sanity/code-smell/deprecated-config.requirements.txt
@@ -1,4 +1,6 @@
# edit "deprecated-config.requirements.in" and generate with: hacking/update-sanity-requirements.py --test deprecated-config
+# pre-build requirement: pyyaml == 6.0
+# pre-build constraint: Cython < 3.0
Jinja2==3.1.2
-MarkupSafe==2.1.3
-PyYAML==6.0.1
+MarkupSafe==2.1.1
+PyYAML==6.0
diff --git a/test/sanity/code-smell/obsolete-files.json b/test/sanity/code-smell/obsolete-files.json
index 3f69cdd6..02d39204 100644
--- a/test/sanity/code-smell/obsolete-files.json
+++ b/test/sanity/code-smell/obsolete-files.json
@@ -1,8 +1,6 @@
{
"include_symlinks": true,
"prefixes": [
- "docs/",
- "examples/",
"test/runner/",
"test/sanity/ansible-doc/",
"test/sanity/compile/",
diff --git a/test/sanity/code-smell/package-data.requirements.in b/test/sanity/code-smell/package-data.requirements.in
index 81b58bcf..3162feb6 100644
--- a/test/sanity/code-smell/package-data.requirements.in
+++ b/test/sanity/code-smell/package-data.requirements.in
@@ -1,8 +1,8 @@
build # required to build sdist
wheel # required to build wheel
jinja2
-pyyaml
-resolvelib < 1.1.0
-rstcheck < 6 # newer versions have too many dependencies
+pyyaml # ansible-core requirement
+resolvelib < 0.9.0
+rstcheck < 4 # match version used in other sanity tests
antsibull-changelog
-setuptools == 66.1.0 # minimum supported setuptools
+setuptools == 45.2.0 # minimum supported setuptools
diff --git a/test/sanity/code-smell/package-data.requirements.txt b/test/sanity/code-smell/package-data.requirements.txt
index ce0fb9cf..b66079d0 100644
--- a/test/sanity/code-smell/package-data.requirements.txt
+++ b/test/sanity/code-smell/package-data.requirements.txt
@@ -1,17 +1,18 @@
# edit "package-data.requirements.in" and generate with: hacking/update-sanity-requirements.py --test package-data
-antsibull-changelog==0.23.0
-build==1.0.3
-docutils==0.18.1
+# pre-build requirement: pyyaml == 6.0
+# pre-build constraint: Cython < 3.0
+antsibull-changelog==0.16.0
+build==0.10.0
+docutils==0.17.1
Jinja2==3.1.2
-MarkupSafe==2.1.3
-packaging==23.2
+MarkupSafe==2.1.1
+packaging==21.3
pyproject_hooks==1.0.0
-PyYAML==6.0.1
-resolvelib==1.0.1
-rstcheck==5.0.0
+pyparsing==3.0.9
+PyYAML==6.0
+resolvelib==0.8.1
+rstcheck==3.5.0
semantic-version==2.10.0
-setuptools==66.1.0
+setuptools==45.2.0
tomli==2.0.1
-types-docutils==0.18.3
-typing_extensions==4.8.0
-wheel==0.41.2
+wheel==0.41.0
diff --git a/test/sanity/code-smell/pymarkdown.config.json b/test/sanity/code-smell/pymarkdown.config.json
deleted file mode 100644
index afe83a35..00000000
--- a/test/sanity/code-smell/pymarkdown.config.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "plugins": {
- "line-length": {
- "line_length": 160,
- "code_block_line_length": 160
- },
- "first-line-heading": {
- "enabled": false
- }
- }
-}
diff --git a/test/sanity/code-smell/pymarkdown.json b/test/sanity/code-smell/pymarkdown.json
deleted file mode 100644
index 986848db..00000000
--- a/test/sanity/code-smell/pymarkdown.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "output": "path-line-column-code-message",
- "error_code": "ansible-test",
- "extensions": [
- ".md"
- ]
-}
diff --git a/test/sanity/code-smell/pymarkdown.py b/test/sanity/code-smell/pymarkdown.py
deleted file mode 100644
index 721c8937..00000000
--- a/test/sanity/code-smell/pymarkdown.py
+++ /dev/null
@@ -1,64 +0,0 @@
-"""Sanity test for Markdown files."""
-from __future__ import annotations
-
-import pathlib
-import re
-import subprocess
-import sys
-
-import typing as t
-
-
-def main() -> None:
- paths = sys.argv[1:] or sys.stdin.read().splitlines()
-
- cmd = [
- sys.executable,
- '-m', 'pymarkdown',
- '--config', pathlib.Path(__file__).parent / 'pymarkdown.config.json',
- '--strict-config',
- 'scan',
- ] + paths
-
- process = subprocess.run(
- cmd,
- stdin=subprocess.DEVNULL,
- capture_output=True,
- check=False,
- text=True,
- )
-
- if process.stderr:
- print(process.stderr.strip(), file=sys.stderr)
- sys.exit(1)
-
- if not (stdout := process.stdout.strip()):
- return
-
- pattern = re.compile(r'^(?P<path_line_column>[^:]*:[0-9]+:[0-9]+): (?P<code>[^:]*): (?P<message>.*) \((?P<aliases>.*)\)$')
- matches = parse_to_list_of_dict(pattern, stdout)
- results = [f"{match['path_line_column']}: {match['aliases'].split(', ')[0]}: {match['message']}" for match in matches]
-
- print('\n'.join(results))
-
-
-def parse_to_list_of_dict(pattern: re.Pattern, value: str) -> list[dict[str, t.Any]]:
- matched = []
- unmatched = []
-
- for line in value.splitlines():
- match = re.search(pattern, line)
-
- if match:
- matched.append(match.groupdict())
- else:
- unmatched.append(line)
-
- if unmatched:
- raise Exception('Pattern {pattern!r} did not match values:\n' + '\n'.join(unmatched))
-
- return matched
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/sanity/code-smell/pymarkdown.requirements.in b/test/sanity/code-smell/pymarkdown.requirements.in
deleted file mode 100644
index f0077713..00000000
--- a/test/sanity/code-smell/pymarkdown.requirements.in
+++ /dev/null
@@ -1 +0,0 @@
-pymarkdownlnt
diff --git a/test/sanity/code-smell/pymarkdown.requirements.txt b/test/sanity/code-smell/pymarkdown.requirements.txt
deleted file mode 100644
index f906e140..00000000
--- a/test/sanity/code-smell/pymarkdown.requirements.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# edit "pymarkdown.requirements.in" and generate with: hacking/update-sanity-requirements.py --test pymarkdown
-application-properties==0.8.1
-Columnar==1.4.1
-pymarkdownlnt==0.9.13.4
-PyYAML==6.0.1
-tomli==2.0.1
-toolz==0.12.0
-typing_extensions==4.8.0
-wcwidth==0.2.8
diff --git a/test/sanity/code-smell/release-names.py b/test/sanity/code-smell/release-names.py
index cac3071d..81d90d81 100644
--- a/test/sanity/code-smell/release-names.py
+++ b/test/sanity/code-smell/release-names.py
@@ -22,7 +22,7 @@ Test that the release name is present in the list of used up release names
from __future__ import annotations
-import pathlib
+from yaml import safe_load
from ansible.release import __codename__
@@ -30,7 +30,8 @@ from ansible.release import __codename__
def main():
"""Entrypoint to the script"""
- releases = pathlib.Path('.github/RELEASE_NAMES.txt').read_text().splitlines()
+ with open('.github/RELEASE_NAMES.yml') as f:
+ releases = safe_load(f.read())
# Why this format? The file's sole purpose is to be read by a human when they need to know
# which release names have already been used. So:
@@ -40,7 +41,7 @@ def main():
if __codename__ == name:
break
else:
- print(f'.github/RELEASE_NAMES.txt: Current codename {__codename__!r} not present in the file')
+ print('.github/RELEASE_NAMES.yml: Current codename was not present in the file')
if __name__ == '__main__':
diff --git a/test/sanity/code-smell/release-names.requirements.in b/test/sanity/code-smell/release-names.requirements.in
new file mode 100644
index 00000000..c3726e8b
--- /dev/null
+++ b/test/sanity/code-smell/release-names.requirements.in
@@ -0,0 +1 @@
+pyyaml
diff --git a/test/sanity/code-smell/release-names.requirements.txt b/test/sanity/code-smell/release-names.requirements.txt
new file mode 100644
index 00000000..bb6a130c
--- /dev/null
+++ b/test/sanity/code-smell/release-names.requirements.txt
@@ -0,0 +1,4 @@
+# edit "release-names.requirements.in" and generate with: hacking/update-sanity-requirements.py --test release-names
+# pre-build requirement: pyyaml == 6.0
+# pre-build constraint: Cython < 3.0
+PyYAML==6.0
diff --git a/test/sanity/code-smell/test-constraints.py b/test/sanity/code-smell/test-constraints.py
index ac5bb4eb..df30fe12 100644
--- a/test/sanity/code-smell/test-constraints.py
+++ b/test/sanity/code-smell/test-constraints.py
@@ -65,6 +65,12 @@ def main():
# keeping constraints for tests other than sanity tests in one file helps avoid conflicts
print('%s:%d:%d: put the constraint (%s%s) in `%s`' % (path, lineno, 1, name, raw_constraints, constraints_path))
+ for name, requirements in frozen_sanity.items():
+ if len(set(req[3].group('constraints').strip() for req in requirements)) != 1:
+ for req in requirements:
+ print('%s:%d:%d: sanity constraint (%s) does not match others for package `%s`' % (
+ req[0], req[1], req[3].start('constraints') + 1, req[3].group('constraints'), name))
+
def check_ansible_test(path: str, requirements: list[tuple[int, str, re.Match]]) -> None:
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent.joinpath('lib')))
diff --git a/test/sanity/code-smell/update-bundled.requirements.txt b/test/sanity/code-smell/update-bundled.requirements.txt
index 53f1e434..d9785e7b 100644
--- a/test/sanity/code-smell/update-bundled.requirements.txt
+++ b/test/sanity/code-smell/update-bundled.requirements.txt
@@ -1,2 +1,3 @@
# edit "update-bundled.requirements.in" and generate with: hacking/update-sanity-requirements.py --test update-bundled
-packaging==23.2
+packaging==21.3
+pyparsing==3.0.9