mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 19:07:17 +01:00
`_holds_grab` asked `grab_current() is self._root`, but our own transient children take the grab for themselves: a posted Tk menu grabs the menu window, so the test read "the grab was lost" and `grab_set_global()` took it back a second later, off our own widget mid-interaction. That is what made screen-locker's sport selector unusable while locked on 2026-07-26. The predicate is now `grab_current() is not None` -- any window we own means the lock still has pointer and keyboard -- and it is public, `holds_grab`, so an embedder can ask the same question instead of re-deriving it. Anything that does not resolve against our widget map (a Tcl-created `ttk.Combobox` popdown, a stale name) raises `KeyError` and counts as lost: fail closed, because losing a popdown beats believing we hold a grab we do not. The blind spot for a second `tk.Tk()` reporting its root as "." is unchanged from the old test, and now written down. `_verify` and `_drain` scheduled the next tick *after* running it, so any exception ended all re-assertion of coverage, grab and VT for the rest of the lock -- the exact fail-open this module exists to prevent, in a file whose docstring is a monotonicity proof. The reschedule moves into `finally`, and the warnings only fire when the reason changes: these states can last the whole lock, and a 1Hz journal stream is not the alternative to silence. The pre-commit side: both subproject configs were written as if cwd were the subproject, but pre-commit runs hooks from the git root -- which is ~/utils, not gatelock. Every pushed run since at least 2026-07-11 has been red, and for compounding reasons: pylint and bandit could not find their config, bandit's tests exclusion never matched, the pytest hook ran with no config at all, and with no `files:` filter each config linted the *whole* monorepo, so gatelock's mypy was type-checking crdt-sync. All paths are now root-relative, each config is scoped to its own subproject, and the pytest hook goes through a shared `scripts/run_subproject_tests.sh` that supplies the missing `cd` and fails loudly if the subproject is gone. Scoping via `files:` has one sharp edge -- rename the directory and the regex matches nothing, so every hook passes on zero files, green and useless. An `always_run` scope-guard hook turns that silent pass into a failure. bandit 1.7.10 threw inside its AST visitor on Python 3.14 and *skipped* every file while still reporting zero issues; 1.9.4 actually scans. Codespell was also flagging a real typo the noise had buried. Housekeeping the above turned up: `gatelock/.github/` and `crdt-sync/.github/` were dead -- GitHub only reads the root `.github/workflows`, which already has all four jobs -- and the two subproject `.gitignore`s were byte-identical to each other and subsumed by the new root one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ============================================================================
|
|
# Run one subproject's test suite from that subproject's directory.
|
|
#
|
|
# Every subproject here keeps its own pyproject.toml, and its pytest config
|
|
# (testpaths, --cov=..., coverage source) is relative to that directory --
|
|
# but pre-commit always runs hooks from the monorepo's git root. This wrapper
|
|
# supplies the missing `cd`, and fails loudly if the subproject is gone,
|
|
# rather than silently testing nothing.
|
|
#
|
|
# Usage: scripts/run_subproject_tests.sh <subproject> [pytest args...]
|
|
# ============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
readonly REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
readonly SCRIPT_NAME="$(basename "$0")"
|
|
|
|
usage() {
|
|
echo "Usage: $SCRIPT_NAME <subproject> [pytest args...]"
|
|
echo " <subproject> directory under $REPO_ROOT holding a pyproject.toml"
|
|
exit 1
|
|
}
|
|
|
|
main() {
|
|
if [[ $# -lt 1 ]]; then
|
|
usage
|
|
fi
|
|
local subproject="$1"
|
|
shift
|
|
local project_dir="$REPO_ROOT/$subproject"
|
|
|
|
if [[ ! -f "$project_dir/pyproject.toml" ]]; then
|
|
echo "Error: no $subproject/pyproject.toml under $REPO_ROOT" >&2
|
|
echo " (was the subproject renamed or removed?)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd "$project_dir"
|
|
exec python -m pytest "$@"
|
|
}
|
|
|
|
main "$@"
|