Skip to content

Commit

Permalink
Simplify line splitting in the CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppentchev authored and terrelln committed Mar 20, 2023
1 parent 29b8a3d commit 3b001a3
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions tests/cli-tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,12 @@ def pop_line(data: bytes) -> typing.Tuple[typing.Optional[bytes], bytes]:
if data == b'':
return (None, data)

newline_idx = data.find(b"\n")
if newline_idx == -1:
end_idx = len(data)
else:
end_idx = newline_idx + 1

line = data[:end_idx]
data = data[end_idx:]

assert len(line) != 0
if not line.endswith(NEWLINE):
line += NEWLINE
parts = data.split(NEWLINE, maxsplit=1)
line = parts[0] + NEWLINE
if len(parts) == 1:
return line, b''

return (line, data)
return line, parts[1]


def glob_line_matches(actual: bytes, expect: bytes) -> bool:
Expand Down

0 comments on commit 3b001a3

Please sign in to comment.