mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make docs-build sanity test disabled by default.
This commit is contained in:
parent
ad5fdf5eb7
commit
a7d7df1450
5 changed files with 32 additions and 14 deletions
|
@ -139,6 +139,7 @@ class SanityConfig(TestConfig):
|
||||||
self.test = args.test # type: list [str]
|
self.test = args.test # type: list [str]
|
||||||
self.skip_test = args.skip_test # type: list [str]
|
self.skip_test = args.skip_test # type: list [str]
|
||||||
self.list_tests = args.list_tests # type: bool
|
self.list_tests = args.list_tests # type: bool
|
||||||
|
self.allow_disabled = args.allow_disabled # type: bool
|
||||||
|
|
||||||
if args.base_branch:
|
if args.base_branch:
|
||||||
self.base_branch = args.base_branch # str
|
self.base_branch = args.base_branch # str
|
||||||
|
|
|
@ -72,6 +72,12 @@ def command_sanity(args):
|
||||||
|
|
||||||
if args.test:
|
if args.test:
|
||||||
tests = [t for t in tests if t.name in args.test]
|
tests = [t for t in tests if t.name in args.test]
|
||||||
|
else:
|
||||||
|
disabled = [t.name for t in tests if not t.enabled and not args.allow_disabled]
|
||||||
|
tests = [t for t in tests if t.enabled or args.allow_disabled]
|
||||||
|
|
||||||
|
if disabled:
|
||||||
|
display.warning('Skipping tests disabled by default without --allow-disabled: %s' % ', '.join(sorted(disabled)))
|
||||||
|
|
||||||
if args.skip_test:
|
if args.skip_test:
|
||||||
tests = [t for t in tests if t.name not in args.skip_test]
|
tests = [t for t in tests if t.name not in args.skip_test]
|
||||||
|
@ -203,19 +209,28 @@ class SanityTest(ABC):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.enabled = True
|
||||||
|
|
||||||
|
|
||||||
class SanityCodeSmellTest(SanityTest):
|
class SanityCodeSmellTest(SanityTest):
|
||||||
"""Sanity test script."""
|
"""Sanity test script."""
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
name = os.path.splitext(os.path.basename(path))[0]
|
name = os.path.splitext(os.path.basename(path))[0]
|
||||||
config = os.path.splitext(path)[0] + '.json'
|
config_path = os.path.splitext(path)[0] + '.json'
|
||||||
|
|
||||||
self.path = path
|
|
||||||
self.config = config if os.path.exists(config) else None
|
|
||||||
|
|
||||||
super(SanityCodeSmellTest, self).__init__(name)
|
super(SanityCodeSmellTest, self).__init__(name)
|
||||||
|
|
||||||
|
self.path = path
|
||||||
|
self.config_path = config_path if os.path.exists(config_path) else None
|
||||||
|
self.config = None
|
||||||
|
|
||||||
|
if self.config_path:
|
||||||
|
with open(self.config_path, 'r') as config_fd:
|
||||||
|
self.config = json.load(config_fd)
|
||||||
|
|
||||||
|
if self.config:
|
||||||
|
self.enabled = not self.config.get('disabled')
|
||||||
|
|
||||||
def test(self, args, targets):
|
def test(self, args, targets):
|
||||||
"""
|
"""
|
||||||
:type args: SanityConfig
|
:type args: SanityConfig
|
||||||
|
@ -233,15 +248,12 @@ class SanityCodeSmellTest(SanityTest):
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
if self.config:
|
if self.config:
|
||||||
with open(self.config, 'r') as config_fd:
|
output = self.config.get('output')
|
||||||
config = json.load(config_fd)
|
extensions = self.config.get('extensions')
|
||||||
|
prefixes = self.config.get('prefixes')
|
||||||
output = config.get('output')
|
files = self.config.get('files')
|
||||||
extensions = config.get('extensions')
|
always = self.config.get('always')
|
||||||
prefixes = config.get('prefixes')
|
text = self.config.get('text')
|
||||||
files = config.get('files')
|
|
||||||
always = config.get('always')
|
|
||||||
text = config.get('text')
|
|
||||||
|
|
||||||
if output == 'path-line-column-message':
|
if output == 'path-line-column-message':
|
||||||
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
|
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
|
||||||
|
|
|
@ -357,6 +357,10 @@ def parse_args():
|
||||||
choices=[test.name for test in sanity_get_tests()],
|
choices=[test.name for test in sanity_get_tests()],
|
||||||
help='tests to skip').completer = complete_sanity_test
|
help='tests to skip').completer = complete_sanity_test
|
||||||
|
|
||||||
|
sanity.add_argument('--allow-disabled',
|
||||||
|
action='store_true',
|
||||||
|
help='allow tests to run which are disabled by default')
|
||||||
|
|
||||||
sanity.add_argument('--list-tests',
|
sanity.add_argument('--list-tests',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='list available tests')
|
help='list available tests')
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"disabled": true,
|
||||||
"always": true,
|
"always": true,
|
||||||
"output": "path-line-column-message"
|
"output": "path-line-column-message"
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,4 @@ esac
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
|
ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
|
||||||
--docker --docker-keep-git --base-branch "${base_branch}" \
|
--docker --docker-keep-git --base-branch "${base_branch}" \
|
||||||
"${options[@]}"
|
"${options[@]}" --allow-disabled
|
||||||
|
|
Loading…
Reference in a new issue