aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-03-25 00:59:46 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-03-25 00:59:46 +0200
commit3e3db7fcff9d577f4d91d6529838fd123bf6840d (patch)
treed4ac9b7c39c8d4d1e4b586d73db66276bf25ea5d
parent010d7f2ab1bc30838e2c9d88e3b8113350d84b3b (diff)
downloadmeson-3e3db7fcff9d577f4d91d6529838fd123bf6840d.zip
meson-3e3db7fcff9d577f4d91d6529838fd123bf6840d.tar.gz
meson-3e3db7fcff9d577f4d91d6529838fd123bf6840d.tar.bz2
Guard against DOS line endings.
-rwxr-xr-xrun_tests.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/run_tests.py b/run_tests.py
index 1cfb42f..c7a7309 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -93,13 +93,16 @@ def run_tests():
def check_file(fname):
linenum = 0
- for line in open(fname).readlines():
- if '\t' in line:
+ for line in open(fname, 'rb').readlines():
+ if b'\t' in line:
print("File %s contains a literal tab on line %d. Only spaces are permitted." % (fname, linenum))
sys.exit(1)
- linenum += 1
+ if b'\r' in line:
+ print("File %s contains DOS line ending on line %d. Only unix-style line endings are permitted." % (fname, linenum))
+ sys.exit(1)
+ linenum += 1
-def check_tabs():
+def check_format():
for (root, dirs, files) in os.walk('.'):
for file in files:
if file.endswith('.py') or file.endswith('.build'):
@@ -110,5 +113,5 @@ if __name__ == '__main__':
script_dir = os.path.split(__file__)[0]
if script_dir != '':
os.chdir(script_dir)
- check_tabs()
+ check_format()
run_tests()