mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-19 03:54:21 +01:00
Log gate helper failures
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZB8QEaFVQoa8CjuAw
This commit is contained in:
parent
f79d425d3d
commit
4b6e4df1bf
@ -44,13 +44,10 @@ def test_helper_followed_by_import(tmp_path: Path) -> None:
|
||||
|
||||
def test_untouched_change_selects_nothing(tmp_path: Path) -> None:
|
||||
_tree(tmp_path)
|
||||
assert (
|
||||
gs.dart_affected_tests(tmp_path, [f"{APP}/lib/lonely.dart"])
|
||||
== [
|
||||
f"{APP}/test/lonely_test.dart",
|
||||
f"{APP}/test/sub/x_test.dart",
|
||||
]
|
||||
)
|
||||
assert gs.dart_affected_tests(tmp_path, [f"{APP}/lib/lonely.dart"]) == [
|
||||
f"{APP}/test/lonely_test.dart",
|
||||
f"{APP}/test/sub/x_test.dart",
|
||||
]
|
||||
assert gs.dart_affected_tests(tmp_path, ["README.md"]) == []
|
||||
|
||||
|
||||
|
||||
@ -9,8 +9,10 @@ loads would otherwise score 100% by absence).
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import sys
|
||||
|
||||
_LOG = logging.getLogger(__name__)
|
||||
APP_LIB = "stronglift_replacement/workout_app/lib/"
|
||||
|
||||
|
||||
@ -39,15 +41,12 @@ def main(argv: list[str]) -> int:
|
||||
for path, lines in sorted(
|
||||
uncovered(Path(argv[1]).read_text(encoding="utf-8"), wanted).items()
|
||||
):
|
||||
if lines is None:
|
||||
print(f"NOT COVERED (no selected test loads it): {path}", file=sys.stderr)
|
||||
if lines is None or lines:
|
||||
_LOG.error("changed file below 100%%: %s (uncovered: %s)", path, "absent from lcov" if lines is None else lines)
|
||||
bad += 1
|
||||
elif lines:
|
||||
print(f"UNCOVERED LINES {path}: {lines}", file=sys.stderr)
|
||||
bad += 1
|
||||
print(f"changed-file coverage: {len(wanted)} files, {bad} below 100%")
|
||||
return 1 if bad else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO, format="push-gate: %(message)s")
|
||||
raise SystemExit(main(sys.argv))
|
||||
|
||||
@ -14,11 +14,13 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict, dataclass, field
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
_LOG = logging.getLogger(__name__)
|
||||
APP = "stronglift_replacement/workout_app"
|
||||
_DIRECTIVE = re.compile(r"^\s*(?:import|export|part)\s[^;]*;", re.MULTILINE)
|
||||
_QUOTED = re.compile(r"'([^']+)'|\"([^\"]+)\"")
|
||||
@ -58,7 +60,7 @@ def _imports(root: Path, rel: str, pkg: str) -> set[str]:
|
||||
try:
|
||||
text = (root / rel).read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as exc:
|
||||
print(f"gate_select: cannot read {rel}: {exc}", file=sys.stderr)
|
||||
_LOG.warning("gate_select: cannot read %s: %s", rel, exc)
|
||||
return out
|
||||
for stmt in _DIRECTIVE.findall(text):
|
||||
for a, b in _QUOTED.findall(stmt):
|
||||
@ -164,10 +166,11 @@ def _git(root: Path, *args: str) -> list[str]:
|
||||
def main(argv: list[str]) -> int:
|
||||
"""Print the selection for BASE..HEAD as JSON."""
|
||||
root = Path(_git(Path.cwd(), "rev-parse", "--show-toplevel")[0])
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
base, head = argv[1], (argv[2] if len(argv) > 2 else "HEAD")
|
||||
changed = _git(root, "diff", "--name-only", f"{base}..{head}")
|
||||
sel = select(root, changed, _git(root, "ls-files", "*.py"))
|
||||
print(json.dumps(asdict(sel), indent=1))
|
||||
sys.stdout.write(json.dumps(asdict(sel), indent=1) + "\n")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user