Hook to check for speech interruption regression.
This commit is contained in:
1 parent
c0e4f7d292
commit
8e98321e6b
3 files changed
+123
No files matched your search
@@ -27,6 +27,30 @@ go run ./cmd/parityledger validate testdata/parity-ledger.csv
|
||||
|
||||
Start verification with the affected packages; run broader checks when the change affects shared behavior or before submission where practical. Format edited Go files with `gofmt`; run `shellcheck` for edited shell scripts. Use deterministic tests and synchronization instead of timing sleeps. Keep fixtures generic, without real usernames or personal identifiers.
|
||||
|
||||
### Speech regression push check
|
||||
|
||||
Run `python3 tests/check_speech.py` for speech queue, title, Wine review metadata,
|
||||
held-key repeat and fresh-key interruption regressions. This uses a private
|
||||
D-Bus session, the race detector and the native build dependencies above;
|
||||
it requires Python 3 and `dbus-run-session`. Required tests must pass: deleting
|
||||
or skipping a required test fails the check. It does not use the active reader,
|
||||
the desktop display, or audible speech.
|
||||
|
||||
To enable this check for local pushes in a clone with no existing pre-push hook:
|
||||
|
||||
```sh
|
||||
ln -s ../../hooks/pre-push .git/hooks/pre-push
|
||||
```
|
||||
|
||||
Preserve and integrate any existing pre-push hook rather than overwriting it.
|
||||
The hook tests each distinct pushed commit tip in a temporary snapshot, so
|
||||
uncommitted fixes cannot mask a broken commit and pushing another branch tests
|
||||
that branch. Failed checks stop a normal local push. Git hooks are local and
|
||||
can be bypassed with `--no-verify`; they do not enforce policy for other clones.
|
||||
Server enforcement needs a required CI check on protected branches. Neither
|
||||
hook results nor CI replace human review, real application listening, physical
|
||||
keyboard checks or Braille acceptance.
|
||||
|
||||
Before extending application orchestration, an event loop, native callback, or settings mapper, identify the subsystem responsible for the policy. Keep ordering and routing in coordinators and feature policy with its existing owner. Specify the owner, lifetime, reset conditions, and cancellation of new mutable state. Prefer cohesive files in existing packages; avoid unnecessary interfaces or packages. If responsibilities need separating, use a behavior-preserving change. Record any urgent-fix follow-up in the contribution description.
|
||||
|
||||
Preserve event order, GLib/cgo ownership, and native lifetimes. Balance key grabs and releases, recover from dead AT-SPI objects, and clean up on shutdown. Keep core input and focus handling bounded and responsive.
|
||||
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repoRoot=$(git rev-parse --show-toplevel)
|
||||
exec python3 "$repoRoot/tests/check_speech.py" --pre-push "$@"
|
||||
Executable
+94
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run required speech regressions, or check each commit tip in a Git push."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
requiredTests = {
|
||||
"TestPrivateWineReviewUpdatesPreserveQueuedTitleSpeech",
|
||||
"TestPrivateWineTitleSurvivesReviewFocusBurst",
|
||||
"TestAutomaticTitleSurvivesMovementRepeatsBeforeAndAfterDelivery",
|
||||
"TestAutomaticTitleStillStopsForExplicitInput",
|
||||
"TestTitleProtectionDoesNotChangeOrdinaryReading",
|
||||
"TestRepeatTrackerRecognizesNativeSequences",
|
||||
}
|
||||
|
||||
|
||||
def run_checks(sourceRoot: Path) -> None:
|
||||
testEnv = os.environ.copy()
|
||||
# Git exports repository paths to hooks. Tests run against the snapshot.
|
||||
for name in tuple(testEnv):
|
||||
if name.startswith("GIT_"):
|
||||
del testEnv[name]
|
||||
testEnv.pop("DISPLAY", None)
|
||||
testEnv.pop("WAYLAND_DISPLAY", None)
|
||||
testEnv["CTHULHU_WINE_TITLE_DBUS"] = "1"
|
||||
command = [
|
||||
"dbus-run-session", "--", "go", "test", "-json", "-race", "-count=1",
|
||||
"-timeout=60s", "-run", "^Test.*(Title|Repeat|Interrupt)|^Test(SpeechWorker|Cancel|WineReview)",
|
||||
"./internal/app", "./internal/input", "./internal/speech", "./internal/wine",
|
||||
]
|
||||
print("Checking speech queues, Wine metadata and key interruption...", flush=True)
|
||||
result = subprocess.run(command, cwd=sourceRoot, env=testEnv, text=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
|
||||
passedTests = set()
|
||||
diagnostics = []
|
||||
for line in result.stdout.splitlines():
|
||||
try:
|
||||
event = json.loads(line)
|
||||
except ValueError:
|
||||
diagnostics.append(line + "\n")
|
||||
continue
|
||||
if "Output" in event:
|
||||
diagnostics.append(event["Output"])
|
||||
if event.get("Action") == "pass" and "Test" in event:
|
||||
passedTests.add(event["Test"])
|
||||
missingTests = requiredTests - passedTests
|
||||
if result.returncode or missingTests:
|
||||
print("".join(diagnostics), end="", file=sys.stderr)
|
||||
if missingTests:
|
||||
print("Required tests did not pass (missing or skipped): " +
|
||||
", ".join(sorted(missingTests)), file=sys.stderr)
|
||||
raise RuntimeError("speech regression check failed")
|
||||
print("Speech regression checks passed.", flush=True)
|
||||
|
||||
|
||||
def check_push(repoRoot: Path) -> None:
|
||||
checkedCommits = set()
|
||||
for line in sys.stdin:
|
||||
localRef, localCommit, remoteRef, remoteCommit = line.split()
|
||||
if set(localCommit) == {"0"} or localCommit in checkedCommits:
|
||||
continue
|
||||
checkedCommits.add(localCommit)
|
||||
print(f"Checking {localRef} ({localCommit[:12]}) before push...", flush=True)
|
||||
with tempfile.TemporaryDirectory(prefix="cthulhu-push-") as directory:
|
||||
sourceRoot = Path(directory)
|
||||
with tempfile.TemporaryFile() as archive:
|
||||
subprocess.run(["git", "archive", "--format=tar", localCommit],
|
||||
cwd=repoRoot, stdout=archive, check=True)
|
||||
archive.seek(0)
|
||||
subprocess.run(["tar", "-xf", "-", "-C", str(sourceRoot)],
|
||||
stdin=archive, check=True)
|
||||
run_checks(sourceRoot)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
repoRoot = Path(__file__).resolve().parents[1]
|
||||
try:
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "--pre-push":
|
||||
check_push(repoRoot)
|
||||
else:
|
||||
run_checks(repoRoot)
|
||||
except (OSError, ValueError, RuntimeError, subprocess.CalledProcessError) as error:
|
||||
print(f"Speech check blocked: {error}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user