Skip to content

Commit

Permalink
Miscellaneous ansible-test fixes. (ansible#28355)
Browse files Browse the repository at this point in the history
* Include .github in test targets. Fix BOTMETA.yml.
* Include bin in compile tests.
* Exclude links from test targets.
* Include bin in pep8 and pylint tests.
* Fix pep8 and pylint issues in bin dir.
  • Loading branch information
mattclay authored Aug 17, 2017
1 parent e801187 commit 8e0b580
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .github/BOTMETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ files:
$modules/remote_management/hpilo/: dagwieers haad
$modules/remote_management/imc/: dagwieers
$modules/remote_management/ipmi/: cloudnull
$modules/remote_management/manageiq/ : $team_manageiq
$modules/remote_management/manageiq/: $team_manageiq
$modules/remote_management/stacki/stacki_host.py: bbyhuy bsanders
$modules/remote_management/wakeonlan.py: dagwieers
$modules/source_control/bzr.py: andreparames
Expand Down Expand Up @@ -903,9 +903,6 @@ files:
$module_utils/dellos:
maintainers: skg-net
labels: networking
$module_utils/eos.py:
maintainers: $team_networking
labels: networking
$module_utils/f5_utils.py:
maintainers: caphrim007
labels: networking
Expand Down
2 changes: 1 addition & 1 deletion bin/ansible
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ from ansible.module_utils._text import to_text


########################################
### OUTPUT OF LAST RESORT ###
# OUTPUT OF LAST RESORT
class LastResort(object):
def display(self, msg):
print(msg, file=sys.stderr)
Expand Down
5 changes: 3 additions & 2 deletions bin/ansible-connection
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def do_fork():
return pid
# This is done as a 'good practice' for daemons, but we need to keep the cwd
# leaving it here as a note that we KNOW its good practice but are not doing it on purpose.
#os.chdir("/")
# os.chdir("/")
os.setsid()
os.umask(0)

Expand Down Expand Up @@ -261,6 +261,7 @@ def communicate(sock, data):
stderr = recv_data(sock)
return (rc, stdout, stderr)


def main():
# Need stdin as a byte stream
if PY3:
Expand Down Expand Up @@ -304,7 +305,7 @@ def main():
socket_path = unfrackpath(cp % dict(directory=tmp_path))

# if the socket file doesn't exist, spin up the daemon process
lock_fd = os.open(lock_path, os.O_RDWR|os.O_CREAT, 0o600)
lock_fd = os.open(lock_path, os.O_RDWR | os.O_CREAT, 0o600)
fcntl.lockf(lock_fd, fcntl.LOCK_EX)

if not os.path.exists(socket_path):
Expand Down
4 changes: 2 additions & 2 deletions test/runner/lib/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def command_sanity_pep8(args, targets):
skip_paths_set = set(skip_paths)
legacy_paths_set = set(legacy_paths)

paths = sorted(i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and i.path not in skip_paths_set)
paths = sorted(i.path for i in targets.include if (os.path.splitext(i.path)[1] == '.py' or i.path.startswith('bin/')) and i.path not in skip_paths_set)

if not paths:
return SanitySkipped(test)
Expand Down Expand Up @@ -458,7 +458,7 @@ def command_sanity_pylint(args, targets):

skip_paths_set = set(skip_paths)

paths = sorted(i.path for i in targets.include if os.path.splitext(i.path)[1] == '.py' and i.path not in skip_paths_set)
paths = sorted(i.path for i in targets.include if (os.path.splitext(i.path)[1] == '.py' or i.path.startswith('bin/')) and i.path not in skip_paths_set)

if not paths:
return SanitySkipped(test)
Expand Down
24 changes: 20 additions & 4 deletions test/runner/lib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def walk_compile_targets():
"""
:rtype: collections.Iterable[TestTarget]
"""
return walk_test_targets(module_path='lib/ansible/modules/', extensions=('.py',))
return walk_test_targets(module_path='lib/ansible/modules/', extensions=('.py',), extra_dirs=('bin',))


def walk_sanity_targets():
Expand Down Expand Up @@ -276,12 +276,13 @@ def load_integration_prefixes():
return prefixes


def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None):
def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None, extra_dirs=None):
"""
:type path: str | None
:type module_path: str | None
:type extensions: tuple[str] | None
:type prefix: str | None
:type extra_dirs: tuple[str] | None
:rtype: collections.Iterable[TestTarget]
"""
for root, _, file_names in os.walk(path or '.', topdown=False):
Expand All @@ -294,7 +295,7 @@ def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None)
if path is None:
root = root[2:]

if root.startswith('.'):
if root.startswith('.') and root != '.github':
continue

for file_name in file_names:
Expand All @@ -309,7 +310,22 @@ def walk_test_targets(path=None, module_path=None, extensions=None, prefix=None)
if prefix and not name.startswith(prefix):
continue

yield TestTarget(os.path.join(root, file_name), module_path, prefix, path)
file_path = os.path.join(root, file_name)

if os.path.islink(file_path):
continue

yield TestTarget(file_path, module_path, prefix, path)

if extra_dirs:
for extra_dir in extra_dirs:
file_names = os.listdir(extra_dir)

for file_name in file_names:
file_path = os.path.join(extra_dir, file_name)

if os.path.isfile(file_path) and not os.path.islink(file_path):
yield TestTarget(file_path, module_path, prefix, path)


def analyze_integration_target_dependencies(integration_targets):
Expand Down

0 comments on commit 8e0b580

Please sign in to comment.