diff --git a/examples/playbooks/rule-no-tabs.yml b/examples/playbooks/rule-no-tabs.yml index 2ed89e797a..3078e2223c 100644 --- a/examples/playbooks/rule-no-tabs.yml +++ b/examples/playbooks/rule-no-tabs.yml @@ -16,7 +16,18 @@ - name: Should not trigger no-tabs rules # noqa fqcn lineinfile: path: some.txt - regexp: ^\t$ + regexp: "^\t$" + line: string with \t inside + # Disabled as attempt to mock it would trigger an error validating its arguments + # - name: Should not trigger no-tabs rules # noqa fqcn + # win_lineinfile: + # path: some.txt + # regexp: "^\t$" + # line: string with \t inside + - name: Should not trigger no-tabs rules + community.windows.win_lineinfile: + path: some.txt + regexp: "^\t$" line: string with \t inside - name: Should not trigger inside jinja vars: diff --git a/requirements.yml b/requirements.yml index 40b9b57142..1291b293df 100644 --- a/requirements.yml +++ b/requirements.yml @@ -7,3 +7,4 @@ collections: - community.docker - community.general - community.molecule + - community.windows diff --git a/src/ansiblelint/_mockings.py b/src/ansiblelint/_mockings.py index 77bd67e8e6..5c2a9a77d2 100644 --- a/src/ansiblelint/_mockings.py +++ b/src/ansiblelint/_mockings.py @@ -47,7 +47,7 @@ def _make_module_stub(module_name: str, options: Options) -> None: path.mkdir(exist_ok=True, parents=True) _write_module_stub( filename=module_file, - name=module_file, + name=module_name, namespace=namespace, collection=collection, ) diff --git a/src/ansiblelint/rules/no_tabs.py b/src/ansiblelint/rules/no_tabs.py index 281be598f1..2614a1a3ea 100644 --- a/src/ansiblelint/rules/no_tabs.py +++ b/src/ansiblelint/rules/no_tabs.py @@ -29,6 +29,10 @@ class NoTabsRule(AnsibleLintRule): ("lineinfile", "insertbefore"), ("lineinfile", "regexp"), ("lineinfile", "line"), + ("win_lineinfile", "insertafter"), + ("win_lineinfile", "insertbefore"), + ("win_lineinfile", "regexp"), + ("win_lineinfile", "line"), ("ansible.builtin.lineinfile", "insertafter"), ("ansible.builtin.lineinfile", "insertbefore"), ("ansible.builtin.lineinfile", "regexp"), @@ -37,6 +41,10 @@ class NoTabsRule(AnsibleLintRule): ("ansible.legacy.lineinfile", "insertbefore"), ("ansible.legacy.lineinfile", "regexp"), ("ansible.legacy.lineinfile", "line"), + ("community.windows.win_lineinfile", "insertafter"), + ("community.windows.win_lineinfile", "insertbefore"), + ("community.windows.win_lineinfile", "regexp"), + ("community.windows.win_lineinfile", "line"), ] def matchtask( @@ -69,6 +77,12 @@ def test_no_tabs_rule(default_rules_collection: RulesCollection) -> None: "examples/playbooks/rule-no-tabs.yml", rules=default_rules_collection, ).run() - assert results[0].lineno == 10 - assert results[0].message == NoTabsRule().shortdesc - assert len(results) == 2 + expected_results = [ + (10, NoTabsRule().shortdesc), + (13, NoTabsRule().shortdesc), + ] + for i, expected in enumerate(expected_results): + assert len(results) >= i + 1 + assert results[i].lineno == expected[0] + assert results[i].message == expected[1] + assert len(results) == len(expected), results