mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Pass code-smell paths on stdin.
This commit is contained in:
@@ -224,6 +224,7 @@ class SanityCodeSmellTest(SanityTest):
|
|||||||
env = ansible_environment(args, color=False)
|
env = ansible_environment(args, color=False)
|
||||||
|
|
||||||
pattern = None
|
pattern = None
|
||||||
|
data = None
|
||||||
|
|
||||||
if self.config:
|
if self.config:
|
||||||
with open(self.config, 'r') as config_fd:
|
with open(self.config, 'r') as config_fd:
|
||||||
@@ -251,10 +252,11 @@ class SanityCodeSmellTest(SanityTest):
|
|||||||
if not paths:
|
if not paths:
|
||||||
return SanitySkipped(self.name)
|
return SanitySkipped(self.name)
|
||||||
|
|
||||||
cmd += paths
|
data = '\n'.join(paths)
|
||||||
|
|
||||||
|
display.info(data, verbosity=4)
|
||||||
try:
|
try:
|
||||||
stdout, stderr = run_command(args, cmd, env=env, capture=True)
|
stdout, stderr = run_command(args, cmd, data=data, env=env, capture=True)
|
||||||
status = 0
|
status = 0
|
||||||
except SubprocessError as ex:
|
except SubprocessError as ex:
|
||||||
stdout = ex.stdout
|
stdout = ex.stdout
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def main():
|
|||||||
'test/'
|
'test/'
|
||||||
]
|
]
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/six/__init__.py',
|
'lib/ansible/module_utils/six/__init__.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ ASSERT_RE = re.compile(r'.*(?<![-:a-zA-Z#][ -])\bassert\b(?!:).*')
|
|||||||
def main():
|
def main():
|
||||||
failed = False
|
failed = False
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
for i, line in enumerate(f.readlines()):
|
for i, line in enumerate(f.readlines()):
|
||||||
matches = ASSERT_RE.findall(line)
|
matches = ASSERT_RE.findall(line)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/six/__init__.py',
|
'lib/ansible/module_utils/six/__init__.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/six/__init__.py',
|
'lib/ansible/module_utils/six/__init__.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/six/__init__.py',
|
'lib/ansible/module_utils/six/__init__.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/six/__init__.py',
|
'lib/ansible/module_utils/six/__init__.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ def main():
|
|||||||
|
|
||||||
basic_allow_once = True
|
basic_allow_once = True
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ FILTER_RE = re.compile(r'((.+?)\s*(?P<left>[\w \.\'"]+)(\s*)\|(\s*)(?P<filter>\w
|
|||||||
def main():
|
def main():
|
||||||
failed = False
|
failed = False
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
text = f.read()
|
text = f.read()
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ def main():
|
|||||||
'test/units/modules/system/interfaces_file/test_interfaces_file.py',
|
'test/units/modules/system/interfaces_file/test_interfaces_file.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ def main():
|
|||||||
'lib/ansible/module_utils/urls.py',
|
'lib/ansible/module_utils/urls.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ def main():
|
|||||||
'test/sanity/code-smell/%s' % os.path.basename(__file__),
|
'test/sanity/code-smell/%s' % os.path.basename(__file__),
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def main():
|
|||||||
'lib/ansible/modules/files/find.py',
|
'lib/ansible/modules/files/find.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ def main():
|
|||||||
'docs/bin/plugin_formatter.py',
|
'docs/bin/plugin_formatter.py',
|
||||||
])
|
])
|
||||||
|
|
||||||
for path in sys.argv[1:]:
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||||||
if path in skip:
|
if path in skip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user