From 321def3c305ce631ca50c8aa8187bb58c14ef669 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Fri, 4 Apr 2025 00:54:48 -0300 Subject: [PATCH] adjust stack_offset for test_limbo_cli --- testing/cli_tests/test_limbo_cli.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/testing/cli_tests/test_limbo_cli.py b/testing/cli_tests/test_limbo_cli.py index 8436fb6df..ddd59695e 100755 --- a/testing/cli_tests/test_limbo_cli.py +++ b/testing/cli_tests/test_limbo_cli.py @@ -75,11 +75,14 @@ class LimboShell: def _handle_error(self) -> bool: while True: - error_output = self.pipe.stderr.read(PIPE_BUF) - if error_output == b"": - return True - console.error(error_output.decode(), end="") - return False + ready, _, errors = select.select( + [self.pipe.stderr], [], [self.pipe.stderr], 0 + ) + if not (ready + errors): + break + error_output = self.pipe.stderr.read(PIPE_BUF).decode() + console.error(error_output, end="", _stack_offset=2) + raise RuntimeError("Error encountered in Limbo shell.") @staticmethod def _clean_output(output: str, marker: str) -> str: @@ -129,7 +132,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3) self.shell.quit() def run_test(self, name: str, sql: str, expected: str) -> None: - console.info(f"Running test: {name}") + console.info(f"Running test: {name}", _stack_offset=2) actual = self.shell.execute(sql) assert actual == expected, ( f"Test failed: {name}\n" @@ -139,9 +142,9 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3) ) def debug_print(self, sql: str): - console.debug(f"debugging: {sql}") + console.debug(f"debugging: {sql}", _stack_offset=2) actual = self.shell.execute(sql) - console.debug(f"OUTPUT:\n{repr(actual)}") + console.debug(f"OUTPUT:\n{repr(actual)}", _stack_offset=2) def run_test_fn( self, sql: str, validate: Callable[[str], bool], desc: str = "" @@ -149,7 +152,7 @@ INSERT INTO t VALUES (zeroblob(1024 - 1), zeroblob(1024 - 2), zeroblob(1024 - 3) # Print the test that is executing before executing the sql command # Printing later confuses the user of the code what test has actually failed if desc: - console.info(f"Testing: {desc}") + console.info(f"Testing: {desc}", _stack_offset=2) actual = self.shell.execute(sql) assert validate(actual), f"Test failed\nSQL: {sql}\nActual:\n{repr(actual)}"