summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/tests/source.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/source4/scripting/python/samba/tests/source.py b/source4/scripting/python/samba/tests/source.py
index 06e8739dc2..0876b043d0 100644
--- a/source4/scripting/python/samba/tests/source.py
+++ b/source4/scripting/python/samba/tests/source.py
@@ -33,7 +33,6 @@ from samba.tests import (
)
-
def get_python_source_files():
"""Iterate over all Python source files."""
library_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "samba"))
@@ -184,6 +183,26 @@ class TestSource(TestCase):
self.fail(self._format_message(illegal_newlines,
'Non-unix newlines were found in the following source files:'))
+ def test_shebang_lines(self):
+ """Check that files with shebang lines and only those are executable."""
+ files_with_shebang = {}
+ files_without_shebang= {}
+ for fname, line_no, line in self._iter_source_files_lines():
+ if line_no >= 1:
+ continue
+ executable = (os.stat(fname).st_mode & 0111)
+ has_shebang = line.startswith("#!")
+ if has_shebang and not executable:
+ self._push_file(files_with_shebang, fname, line_no)
+ if not has_shebang and executable:
+ self._push_file(files_without_shebang, fname, line_no)
+ if files_with_shebang:
+ self.fail(self._format_message(files_with_shebang,
+ 'Files with shebang line that are not executable:'))
+ if files_without_shebang:
+ self.fail(self._format_message(files_without_shebang,
+ 'Files without shebang line that are executable:'))
+
pep8_ignore = [
'E401', # multiple imports on one line
'E501', # line too long