Skip to content

Commit 91f143e

Browse files
committed
Test that no file name exceeds max len of 143
LUCKS and most Linux encrypted FS only support up to 143-long file names and long names will make it impossible to install or checkout ScanCode Reference: #2901 Reported-by: Michael McMahon <[email protected]> Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent d2f5bda commit 91f143e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tests/scancode/test_scancode_checks.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
import subprocess
1313
import sys
1414
import unittest
15-
15+
from commoncode.fileutils import resource_iter
1616

1717
"""
18-
This test suite runs code checks such as:
18+
This test suite runs various code checks such as:
1919
- code style
2020
- ABOUT files
2121
- release archives creation
22-
22+
2323
NOTE: it has imports limited to the standard library by design
2424
"""
2525

26-
2726
root_dir = dirname(dirname(dirname(__file__)))
2827

2928
on_linux = str(sys.platform).lower().startswith('linux')
3029

3130

3231
@unittest.skipIf(not on_linux, 'Check about files only on one OS')
3332
class TestCheckAboutFiles(unittest.TestCase):
33+
3434
def test_about_files_src(self):
3535
subprocess.check_output('venv/bin/about check src/'.split(), cwd=root_dir)
3636

@@ -50,3 +50,18 @@ def test_codestyle(self):
5050
'venv/bin/pycodestyle --ignore E501,W503,W504,W605 '
5151
'--exclude=lib,lib64,thirdparty,'
5252
'docs,bin,migrations,settings,local,tmp .'.split(), cwd=root_dir)
53+
54+
55+
@unittest.skipIf(not on_linux, 'Check file length only on one OS')
56+
class TestFilenameMaxLength(unittest.TestCase):
57+
58+
def test_file_name_are_not_too_long(self):
59+
60+
# See https://unix.stackexchange.com/questions/32795/what-is-the-maximum-allowed-filename-and-folder-size-with-ecryptfs
61+
# 143 is the max filename length that luks and ecryptfs support!
62+
63+
long_filenames = [r for r in resource_iter('src') if len(r.split('/')[-1]) > 143]
64+
long_filenames.extend(r for r in resource_iter('tests') if len(r.split('/')[-1]) > 143)
65+
if long_filenames:
66+
msg = '\n'.join(long_filenames)
67+
raise Exception(f'These filenames are too long (over 143 characters):\n{msg}')

0 commit comments

Comments
 (0)