From 2a5c5858c5247f7ab620f02dcc8ad7df8b4eb1ea Mon Sep 17 00:00:00 2001 From: hugsy Date: Sun, 10 Nov 2024 12:20:46 -0800 Subject: [PATCH] test fix --- gef.py | 2 +- tests/base.py | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/gef.py b/gef.py index ba3cc6851..e71b18e69 100644 --- a/gef.py +++ b/gef.py @@ -11736,7 +11736,7 @@ def target_remote_posthook(): gef.session.remote = GefRemoteSessionManager(conn) # switch back context to its old context - gef.config["context.enable"] = gef.temp.pop("context_old_value", False) + gef.config["context.enable"] = gef.temp.pop("context_old_value", True) # if here, no exception was thrown, print context gdb.execute("context") diff --git a/tests/base.py b/tests/base.py index 2752ea361..f96679138 100644 --- a/tests/base.py +++ b/tests/base.py @@ -61,20 +61,6 @@ def __setup(self): # self._port = get_random_port() self._commands = "" - - if COVERAGE_DIR: - self._coverage_file = pathlib.Path(COVERAGE_DIR) / os.getenv( - "PYTEST_XDIST_WORKER", "gw0" - ) - self._commands += f""" -pi import coverage -pi cov = coverage.Coverage(data_file="{self._coverage_file}", auto_data=True, branch=True) -pi cov.start() -""" - - # self._initfile = tempfile.NamedTemporaryFile(mode="w", delete=False) - # self._initfile.write(self._commands) - # self._initfile.flush() self._command = [ # fmt: off self._gdb_path, "-q", "-nx", @@ -84,10 +70,37 @@ def __setup(self): "-ex", "gef config gef.disable_color True", "-ex", f"source {RPYC_GEF_PATH}", "-ex", f"pi start_rpyc_service({self._port})", - "--", - # fmt: off - str(self._target.absolute()), # type: ignore pylint: disable=E1101 + # fmt: on ] + + if COVERAGE_DIR: + self._coverage_file = pathlib.Path(COVERAGE_DIR) / os.getenv( + "PYTEST_XDIST_WORKER", "gw0" + ) + self._command.extend(("-ex", + f"""pi import coverage; cov = coverage.Coverage(data_file="{self._coverage_file}", auto_data=True, branch=True); cov.start()""")) + + + # self._initfile = tempfile.NamedTemporaryFile(mode="w", delete=False) + # self._initfile.write(self._commands) + # self._initfile.flush() + # self._command = [ + # # fmt: off + # self._gdb_path, "-q", "-nx", + # "-ex", f"source {GEF_PATH}", + # "-ex", "gef config gef.debug True", + # "-ex", "gef config gef.propagate_debug_exception True", + # "-ex", "gef config gef.disable_color True", + # "-ex", f"source {RPYC_GEF_PATH}", + # "-ex", f"pi start_rpyc_service({self._port})", + # "--", + # # fmt: off + self._command.extend( + ("-ex", + str(self._target.absolute()) # type: ignore pylint: disable=E1101 + ) + ) + # ] self._process = subprocess.Popen(self._command) assert self._process.pid > 0 time.sleep(RPYC_SPAWN_TIME)