mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-01 12:20:02 +00:00
Fixed underflow issue with truncating test/bench -C/--context
There was no check on context > stdout, so requesting more context than was actually printed by the test could result in a negative value. Python "helpfully" interpreted this as a negative index, resulting in somewhat random context lengths. This, combined with my tendency to just default to a large number like --context=100, led to me thinking a test was printing much less than it actually was... Don't get me wrong, I love Python, and I think Python's negative indices are a clever way to add flexibility to slice notation, but the value-dependent semantics are a pretty unfortunate footgun...
This commit is contained in:
@ -1306,7 +1306,7 @@ def run(runner, test_ids=[], **args):
|
||||
stdout = failure.stdout
|
||||
if failure.assert_ is not None:
|
||||
stdout = stdout[:-1]
|
||||
for line in stdout[len(stdout)-args.get('context', 5):]:
|
||||
for line in stdout[max(len(stdout)-args.get('context', 5), 0):]:
|
||||
sys.stdout.write(line)
|
||||
|
||||
if failure.assert_ is not None:
|
||||
|
||||
Reference in New Issue
Block a user