forked from ansible/ansible-lint
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include opt-in rules when verbosely listing tags and rules
With PR ansible#1450 optional rules with the 'opt-in' tag were introduced and according to the docs, listing rules and tags with `-v` should also list the opt-in rules. Fixes: ansible#2068 Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
- Loading branch information
1 parent
cd32348
commit fad94d4
Showing
5 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Tests related to our logging/verbosity setup.""" | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
from ansiblelint.testing import run_ansible_lint | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("result", "verbosity"), | ||
((False, ""), (True, "-v")), | ||
ids=("default verbosity", "more verbose"), | ||
) | ||
def test_list_rules_with_verbosity_includes_opt_in_rules( | ||
result: bool, verbosity: str | ||
) -> None: | ||
"""Checks that listing rules with verbosity level at least set to -v also includes the opt-in rules.""" | ||
# Piggyback off the .yamllint in the root of the repo, just for testing. | ||
# We'll "override" it with the one in the fixture. | ||
cwd = os.path.realpath( | ||
os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") | ||
) | ||
fakerole = os.path.join("test", "fixtures", "list-rules-tests") | ||
|
||
result_list_rules = run_ansible_lint(verbosity, "-L", fakerole, cwd=cwd) | ||
|
||
assert ("opt-in" in result_list_rules.stdout) is result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("result", "verbosity"), | ||
((False, ""), (True, "-v")), | ||
ids=("default verbosity", "more verbose"), | ||
) | ||
def test_list_tags_with_verbosity_includes_opt_in_rules( | ||
result: bool, verbosity: str | ||
) -> None: | ||
"""Checks that listing tags with verbosity level at least set to -v also includes the opt-in rules.""" | ||
# Piggyback off the .yamllint in the root of the repo, just for testing. | ||
# We'll "override" it with the one in the fixture. | ||
cwd = os.path.realpath( | ||
os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") | ||
) | ||
fakerole = os.path.join("test", "fixtures", "list-rules-tests") | ||
|
||
result_list_rules = run_ansible_lint(verbosity, "-L", fakerole, cwd=cwd) | ||
|
||
assert ("opt-in" in result_list_rules.stdout) is result |