Fix shebangs and file modes and update tests. (#40563)

* Add execute bit sanity test and apply fixes.
* Add shebang test for `lib` dirs and apply fixes.
* Shebang and execute bit cleanup.
This commit is contained in:
Matt Clay 2018-05-22 14:25:36 -07:00 committed by GitHub
parent f84f3de7c2
commit 8deced3e04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 17 additions and 11 deletions

0
contrib/inventory/lxd.py Normal file → Executable file
View file

0
hacking/fix_test_syntax.py Normal file → Executable file
View file

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

0
lib/ansible/module_utils/gitlab.py Executable file → Normal file
View file

0
lib/ansible/module_utils/manageiq.py Executable file → Normal file
View file

0
lib/ansible/modules/cloud/amazon/ec2_lc.py Executable file → Normal file
View file

View file

0
lib/ansible/modules/cloud/docker/docker_service.py Executable file → Normal file
View file

View file

0
lib/ansible/modules/clustering/k8s/_kubernetes.py Executable file → Normal file
View file

0
lib/ansible/modules/clustering/znode.py Executable file → Normal file
View file

0
lib/ansible/modules/network/aci/aci_aep_to_domain.py Executable file → Normal file
View file

View file

View file

View file

View file

0
lib/ansible/modules/network/bigswitch/bcf_switch.py Executable file → Normal file
View file

0
lib/ansible/modules/network/bigswitch/bigmon_chain.py Executable file → Normal file
View file

0
lib/ansible/modules/network/panos/panos_sag.py Executable file → Normal file
View file

View file

0
lib/ansible/modules/notification/logentries_msg.py Executable file → Normal file
View file

0
lib/ansible/modules/notification/snow_record.py Executable file → Normal file
View file

View file

View file

View file

View file

0
lib/ansible/modules/source_control/gitlab_hooks.py Executable file → Normal file
View file

0
lib/ansible/modules/system/interfaces_file.py Executable file → Normal file
View file

0
lib/ansible/modules/system/service_facts.py Executable file → Normal file
View file

View file

0
lib/ansible/plugins/inventory/foreman.py Executable file → Normal file
View file

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
"""Foreman plugin for integration tests."""
from __future__ import absolute_import, print_function

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
import stat
import sys
@ -24,7 +25,6 @@ def main():
}
skip = set([
'hacking/cherrypick.py',
'test/integration/targets/win_module_utils/library/legacy_only_new_way_win_line_ending.ps1',
'test/integration/targets/win_module_utils/library/legacy_only_old_way_win_line_ending.ps1',
])
@ -35,17 +35,27 @@ def main():
with open(path, 'rb') as path_fd:
shebang = path_fd.readline().strip()
mode = os.stat(path).st_mode
executable = (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) & mode
if not shebang:
continue
if not shebang or not shebang.startswith(b'#!'):
if executable:
print('%s:%d:%d: file without shebang should not be executable' % (path, 0, 0))
if not shebang.startswith(b'#!'):
continue
is_module = False
if path.startswith('lib/ansible/modules/'):
is_module = True
elif path.startswith('lib/') or path.startswith('test/runner/lib/'):
if executable:
print('%s:%d:%d: should not be executable' % (path, 0, 0))
if shebang:
print('%s:%d:%d: should not have a shebang' % (path, 0, 0))
continue
elif path.startswith('test/integration/targets/'):
dirname = os.path.dirname(path)
@ -57,6 +67,9 @@ def main():
is_module = True
if is_module:
if executable:
print('%s:%d:%d: module should not be executable' % (path, 0, 0))
ext = os.path.splitext(path)[1]
expected_shebang = module_shebangs.get(ext)
expected_ext = ' or '.join(['"%s"' % k for k in module_shebangs])

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
# This is a standalone test for the regex inside validate-modules
# It is not suitable to add to the make tests target because the
# file under test is outside the test's sys.path AND has a hyphen

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
#
# (c) 2016 Red Hat Inc.
#
# This file is part of Ansible

View file

0
test/units/modules/source_control/test_gitlab_hooks.py Executable file → Normal file
View file