-
Notifications
You must be signed in to change notification settings - Fork 112
Limit log file name length to OS allowed limit #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Also change root for test_log_file_names tests to be a temporary directory to allow runnig tests without sudo. The old root `/` or `C:` is not usually writable for regular users.
pbos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow response time, new parent here.
| os.remove(log_name) | ||
| except OSError as os_error: | ||
| # truncate file name if error is Errno 36: File name too long | ||
| if os_error.errno == 36: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be errno.ENAMETOOLONG instead of the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Task._normalize(test_name), execution_number) | ||
| # The log file name is a combination of a test binary name and a test name. | ||
| # If the log file name exceeds OS limitations it will be truncated. | ||
| MKSTEMP_RANDOM_LEN = 12 # length of mkstemp random string being added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"# Space reserved for mkstemp suffix."
| # truncate file name if error is Errno 36: File name too long | ||
| if os_error.errno == 36: | ||
| prefix_length = ((os.statvfs('.').f_namemax - | ||
| MKSTEMP_RANDOM_LEN) if hasattr(os, 'statvfs') else MAX_PREFIX_LENGTH) - len(suffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would read easier as: if hasattr(..): prefix_length = ..., i.e. avoid the ternary. as it's long.
| 'Test.case', 1)) | ||
| MAX_PREFIX_LENGTH = 240 | ||
| long_test_name = 'a' * (os.statvfs('.').f_namemax if hasattr(os, | ||
| 'statvfs') else MAX_PREFIX_LENGTH + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this one a separate test? Maybe test_truncates_file_name
Also I think this test only makes sense on systems that have statvfs, can it run conditionally? This test requires OSes without statvfs to reject filenames that are longer which is maybe not what we want. I'm OK with not testing the MAX_PREFIX_LENGTH branch.
No description provided.