mirror of
https://github.com/leanprover/lean4.git
synced 2026-03-17 10:24:07 +00:00
The tests need to run with certain environment variables set that only cmake really knows and that differ between stages. Cmake could just set the variables directly when running the tests and benchmarks, but that would leave no good way to manually run a single benchmark. So cmake generates some stage-specific scripts instead that set the required environment variables. Previously, those scripts were sourced directly by the individual `run_*` scripts, so the env scripts of different stages would overwrite each other. This PR changes the setup so they can instead be generated next to each other. This also simplifies the `run_*` scripts themselves a bit, and makes `tests/bench/build` less of a hack.
40 lines
1.2 KiB
Python
Executable File
40 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Determine paths relative to the current file.
|
|
script_file = Path(__file__)
|
|
src_dir = script_file.parent.parent.parent.parent / "src"
|
|
template_file = script_file.parent / "lakeprof_report_template.html"
|
|
|
|
|
|
def run_stdout(*command: str, cwd: Path | None = None) -> str:
|
|
result = subprocess.run(command, capture_output=True, encoding="utf-8", cwd=cwd)
|
|
if result.returncode != 0:
|
|
print(result.stdout, end="", file=sys.stdout)
|
|
print(result.stderr, end="", file=sys.stderr)
|
|
sys.exit(result.returncode)
|
|
return result.stdout
|
|
|
|
|
|
sha = run_stdout("git", "rev-parse", "@", cwd=src_dir).strip()
|
|
base_url = f"https://speed.lean-lang.org/lean4-out/{sha}"
|
|
report = (src_dir / "lakeprof_report.txt").read_text()
|
|
|
|
template = template_file.read_text()
|
|
template = template.replace("__BASE_URL__", json.dumps(base_url))
|
|
template = template.replace("__LAKEPROF_REPORT__", report)
|
|
(src_dir / "index.html").write_text(template)
|
|
|
|
|
|
def upload(file: Path) -> None:
|
|
subprocess.run(["curl", "-fT", file, f"{base_url}/{file.name}"], check=True)
|
|
|
|
|
|
upload(src_dir / "index.html")
|
|
upload(src_dir / "lakeprof.log")
|
|
upload(src_dir / "lakeprof.trace_event")
|