mirror of
https://github.com/Z3Prover/z3
synced 2026-07-20 14:05:50 +00:00
simplify skill scripts: expose find_repo_root, fix split string, simplify label
- z3db.py: rename _find_repo_root to find_repo_root (make public) and add require_repo_root helper that exits on failure; update docstring and internal caller; fix unnecessary string literal split in log() - memory_safety.py: remove 13-line duplicate find_repo_root function; import and use require_repo_root from z3db instead - static_analysis.py: simplify two-line label assignment in print_findings to a single expression using 'or' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
59bb444694
commit
4dec7b1324
3 changed files with 17 additions and 22 deletions
|
|
@ -18,7 +18,7 @@ import time
|
|||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent / "shared"))
|
||||
from z3db import Z3DB, setup_logging
|
||||
from z3db import Z3DB, require_repo_root, setup_logging
|
||||
|
||||
logger = logging.getLogger("z3agent")
|
||||
|
||||
|
|
@ -52,19 +52,6 @@ def check_dependencies():
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def find_repo_root() -> Path:
|
||||
d = Path.cwd()
|
||||
for _ in range(10):
|
||||
if (d / "CMakeLists.txt").exists() and (d / "src").is_dir():
|
||||
return d
|
||||
parent = d.parent
|
||||
if parent == d:
|
||||
break
|
||||
d = parent
|
||||
logger.error("could not locate Z3 repository root")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def build_is_configured(build_dir: Path, sanitizer: str) -> bool:
|
||||
"""Check whether the build directory already has a matching cmake config."""
|
||||
cache = build_dir / "CMakeCache.txt"
|
||||
|
|
@ -220,7 +207,7 @@ def main():
|
|||
|
||||
setup_logging(args.debug)
|
||||
check_dependencies()
|
||||
repo_root = find_repo_root()
|
||||
repo_root = require_repo_root()
|
||||
|
||||
sanitizers = ["asan", "ubsan"] if args.sanitizer == "both" else [args.sanitizer]
|
||||
all_findings = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue