diff --git a/src/hypofuzz/interface.py b/src/hypofuzz/interface.py index 9d5b1a6..4331037 100644 --- a/src/hypofuzz/interface.py +++ b/src/hypofuzz/interface.py @@ -66,7 +66,6 @@ def pytest_collection_finish(self, session: pytest.Session) -> None: self.fuzz_targets.append(fuzz) except Exception as err: print("crashed in", item.nodeid, err) # noqa - raise def _get_hypothesis_tests_with_pytest(args: Iterable[str]) -> List["FuzzProcess"]: diff --git a/tests/test_e2e.py b/tests/test_e2e.py index c1be9d6..bcd03b6 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -2,8 +2,10 @@ import pytest import requests +import subprocess +import os +import signal -from hypofuzz import entrypoint TEST_CODE = """ from hypothesis import given, settings, strategies as st @@ -31,15 +33,34 @@ def test_end_to_end(numprocesses, tmp_path): """An end-to-end test to start the fuzzer and access the dashboard.""" test_fname = tmp_path / "test_demo2.py" test_fname.write_text(TEST_CODE, encoding="utf-8") - dash_proc = entrypoint._fuzz_impl( - numprocesses=numprocesses, - dashboard=True, - port=7777, - unsafe=False, - pytest_args=["-p", "no:dash", str(test_fname)], + process = subprocess.Popen( + [ + "hypothesis", + "fuzz", + "--numprocesses", + str(numprocesses), + "--port", + "7777", + "--", + "-p", + "no:dash", + str(test_fname), + ], + stdout=subprocess.PIPE, + start_new_session=True ) - assert dash_proc - resp = requests.get("http://localhost:7777", allow_redirects=True, timeout=10) - resp.raise_for_status() - dash_proc.kill() - dash_proc.join() + # wait for dashboard to start up + for _ in range(100): + output = process.stdout.readline() + if b"Now serving dashboard at" in output: + break + else: + raise Exception("dashboard took too long to start up") + + try: + resp = requests.get("http://localhost:7777", allow_redirects=True, timeout=10) + resp.raise_for_status() + finally: + process.stdout.close() + os.killpg(os.getpgid(process.pid), signal.SIGKILL) + process.wait()