mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
fix(bench,cpg): the position benchmark builds in the recipe's language and reports per repository; a doubly-failed build disposes its scratch
WP Statistics's first region is JavaScript, and a build asked for as JavaScript went looking for jssrc2cpg, failed both launchers, lost the whole run's output and left a 9.6 MB scratch directory behind. Also notes upstream: joern#6281 is fixed in v4.0.625. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
c955721f92
commit
b6cccd1444
@@ -1018,3 +1018,27 @@ def test_the_census_checks_the_instrument(caplog: pytest.LogCaptureFixture, monk
|
||||
)._graph_census(tmp_path / "c.bin", tmp_path, "php")
|
||||
assert "512 MB heap where 2048 MB is configured" in caplog.text
|
||||
assert "recompute" not in caplog.text
|
||||
|
||||
|
||||
def test_a_build_that_fails_on_both_launchers_leaves_no_scratch_behind(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Measured: a measurement that asked for the wrong language failed both `joern-parse` and the frontend
|
||||
and left a 9.6 MB `ousast-cpg-*` directory in /tmp. Failure paths dispose too."""
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from openultrasast.cpg.backend import JoernBackend
|
||||
|
||||
(tmp_path / "a.php").write_text("<?php\n")
|
||||
scratch_root = tmp_path / "scratch"
|
||||
scratch_root.mkdir()
|
||||
monkeypatch.setattr(tempfile, "tempdir", str(scratch_root))
|
||||
|
||||
def runner(command, **kwargs): # type: ignore[no-untyped-def]
|
||||
if "-r" in command:
|
||||
return subprocess.CompletedProcess(args=command, returncode=0, stdout="", stderr="")
|
||||
return subprocess.CompletedProcess(args=command, returncode=1, stdout="", stderr="boom")
|
||||
|
||||
monkeypatch.setenv("OPENULTRASAST_JOERN_PROBE", "on")
|
||||
monkeypatch.setattr("shutil.which", lambda name: f"/opt/bin/{name}")
|
||||
assert JoernBackend(runner=runner).build(tmp_path, language="javascript") is None
|
||||
assert list(scratch_root.iterdir()) == [], "the failed build's scratch directory is gone"
|
||||
|
||||
Reference in New Issue
Block a user