v2.9.0 (#641)
Co-authored-by: Antoine <33425718+anth2o@users.noreply.github.com> Co-authored-by: Bastien <bastien.baret@gmail.com> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Robin Gullo <robin.gullo@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
a83c81ecf5
commit
632ea8c032
253 changed files with 13965 additions and 2525 deletions
|
|
@ -49,15 +49,23 @@ def strip_ansi(text: str) -> str:
|
|||
return re.sub(r"\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b\][^\x07]*\x07", "", text)
|
||||
|
||||
|
||||
def poll_until(predicate: Callable[[], bool], timeout: float, message: str) -> None:
|
||||
start = time.monotonic()
|
||||
while time.monotonic() - start < timeout:
|
||||
if predicate():
|
||||
return
|
||||
time.sleep(0.05)
|
||||
raise AssertionError(message)
|
||||
|
||||
|
||||
def wait_for_request_count(
|
||||
request_count_getter: Callable[[], int], expected_count: int, timeout: float
|
||||
) -> None:
|
||||
start = time.monotonic()
|
||||
while time.monotonic() - start < timeout:
|
||||
if request_count_getter() >= expected_count:
|
||||
return
|
||||
time.sleep(0.05)
|
||||
raise AssertionError(f"Timed out waiting for {expected_count} backend request(s).")
|
||||
poll_until(
|
||||
lambda: request_count_getter() >= expected_count,
|
||||
timeout,
|
||||
f"Timed out waiting for {expected_count} backend request(s).",
|
||||
)
|
||||
|
||||
|
||||
def wait_for_main_screen(child: pexpect.spawn, timeout: float = 20.0) -> None:
|
||||
|
|
@ -84,3 +92,24 @@ def wait_for_rendered_text(
|
|||
raise AssertionError(
|
||||
f"Timed out waiting for rendered text: {needle!r}\n\nRendered tail:\n{rendered_tail}"
|
||||
)
|
||||
|
||||
|
||||
def send_ctrl_c_until_quit_confirmation(
|
||||
child: pexpect.spawn, captured: io.StringIO, timeout: float = 3
|
||||
) -> None:
|
||||
"""Send Ctrl+C and wait for quit confirmation prompt. Retries if first Ctrl+C interrupts."""
|
||||
start = time.monotonic()
|
||||
while time.monotonic() - start < timeout:
|
||||
child.sendcontrol("c")
|
||||
try:
|
||||
child.expect(ansi_tolerant_pattern("Press Ctrl+C again to quit"), timeout=2)
|
||||
# Confirmation prompt appeared, send second Ctrl+C
|
||||
child.sendcontrol("c")
|
||||
return
|
||||
except pexpect.TIMEOUT:
|
||||
# First Ctrl+C may have interrupted something, try again
|
||||
continue
|
||||
rendered_tail = strip_ansi(captured.getvalue())[-1200:]
|
||||
raise AssertionError(
|
||||
f"Timed out waiting for quit confirmation prompt.\n\nRendered tail:\n{rendered_tail}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue