Skip to content

The agent that grows with you

test(e2e): strict acceptance mode makes a batch's known gaps hard failures

Teknium53847b7d4193
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 308b9982463..34861a35631 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -22,6 +22,11 @@ on:
required: false
type: boolean
default: false
+ strict_acceptance:
+ description: "Acceptance runs only: known_failure owners whose gaps FAIL this run instead of xfailing ('upd-txn', a comma list, or '1' for every gap). Sets HERMES_E2E_STRICT_ACCEPTANCE for the E2E suites (tests/e2e/core/_pending_fixes.py)."
+ required: false
+ type: string
+ default: ''
workflow_call:
inputs:
release:
@@ -129,6 +134,7 @@ jobs:
with:
e2e: ${{ needs.detect.outputs.e2e == 'true' }}
e2e_upgrade: ${{ needs.detect.outputs.e2e_upgrade == 'true' }}
+ strict_acceptance: ${{ inputs.strict_acceptance || '' }}
# macOS + Windows lanes. The main `tests` lane above is Linux-only, and
# the OS-marked tests it collects are skipped there by design (see the
@@ -148,6 +154,7 @@ jobs:
desktop_updater: ${{ needs.detect.outputs.desktop_updater == 'true' }}
e2e: ${{ needs.detect.outputs.e2e == 'true' }}
e2e_upgrade: ${{ needs.detect.outputs.e2e_upgrade == 'true' }}
+ strict_acceptance: ${{ inputs.strict_acceptance || '' }}
lint:
name: Python lints
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index 451003c9ade..8e335ff7b13 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -55,6 +55,12 @@ on:
type: boolean
required: false
default: true
+ strict_acceptance:
+ description: >-
+ Acceptance runs only: known_failure owners whose gaps FAIL this run instead of xfailing ('upd-txn', a comma list, or '1' for every gap). Sets HERMES_E2E_STRICT_ACCEPTANCE for the E2E suites (tests/e2e/core/_pending_fixes.py).
+ type: string
+ required: false
+ default: ''
permissions:
contents: read
@@ -197,6 +203,8 @@ jobs:
name: Windows install + update E2E
if: inputs.e2e_upgrade
uses: ./.github/workflows/windows-install-update-e2e.yml
+ with:
+ strict_acceptance: ${{ inputs.strict_acceptance }}
e2e-windows:
# Real Hermes processes on a real Windows host (tests/e2e/core/windows): hermes.exe,
@@ -236,6 +244,7 @@ jobs:
scripts/run_tests.sh tests/e2e/core/windows/ -- \
-m "platforms and integration" -v --tb=short -rA
env:
+ HERMES_E2E_STRICT_ACCEPTANCE: ${{ inputs.strict_acceptance }}
HERMES_TEST_WORKERS: '6'
HERMES_TEST_FILE_TIMEOUT: '900'
HERMES_TEST_FILE_RETRIES: '0'
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 98a103c22b5..76f17c52ea9 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -16,6 +16,12 @@ on:
type: boolean
required: false
default: true
+ strict_acceptance:
+ description: >-
+ Acceptance runs only: known_failure owners whose gaps FAIL this run instead of xfailing ('upd-txn', a comma list, or '1' for every gap). Sets HERMES_E2E_STRICT_ACCEPTANCE for the E2E suites (tests/e2e/core/_pending_fixes.py).
+ type: string
+ required: false
+ default: ''
permissions:
contents: read
@@ -182,6 +188,7 @@ jobs:
mapfile -t files < <(find tests/e2e -name 'test_*.py' -not -path 'tests/e2e/core/upgrade/*' | sort)
scripts/run_tests.sh --include-integration "${files[@]}"
env:
+ HERMES_E2E_STRICT_ACCEPTANCE: ${{ inputs.strict_acceptance }}
# An e2e file is a process tree, not one CPU-bound pytest worker. With
# 32 files at once the hosted run starved live children before their
# ready frames (empty stderr, still alive) and hit 60–120s deadlines
@@ -350,6 +357,7 @@ jobs:
scripts/run_tests.sh --include-integration "${files[@]}"
env:
SHARD: ${{ matrix.shard }}
+ HERMES_E2E_STRICT_ACCEPTANCE: ${{ inputs.strict_acceptance }}
# Each file drives real installs/updaters (process trees plus uv and
# git I/O); cpu_count of them at once starves their deadlines. A
# shard holds at most ~7 files, so this runs each shard in one wave.
diff --git a/.github/workflows/windows-install-update-e2e.yml b/.github/workflows/windows-install-update-e2e.yml
index ec1180a6125..2b14c998d03 100644
--- a/.github/workflows/windows-install-update-e2e.yml
+++ b/.github/workflows/windows-install-update-e2e.yml
@@ -14,6 +14,23 @@ name: Windows install + update E2E
on:
workflow_call:
+ inputs:
+ strict_acceptance:
+ description: >-
+ Acceptance runs only: known_failure owners whose gaps FAIL this run instead of xfailing ('upd-txn', a comma list, or '1' for every gap). Sets HERMES_E2E_STRICT_ACCEPTANCE for the E2E suites (tests/e2e/core/_pending_fixes.py).
+ type: string
+ required: false
+ default: ''
+ # An acceptance run of an integrated batch on its own: e.g.
+ # `gh workflow run windows-install-update-e2e.yml --ref <branch> -f strict_acceptance=upd-txn`.
+ workflow_dispatch:
+ inputs:
+ strict_acceptance:
+ description: >-
+ Acceptance runs only: known_failure owners whose gaps FAIL this run instead of xfailing ('upd-txn', a comma list, or '1' for every gap). Sets HERMES_E2E_STRICT_ACCEPTANCE for the E2E suites (tests/e2e/core/_pending_fixes.py).
+ type: string
+ required: false
+ default: ''
push:
branches: ['wine2e-install/**']
@@ -53,6 +70,7 @@ jobs:
-m "platforms and integration" -v --tb=short -rA
env:
HERMES_E2E_WINDOWS_INSTALL: '1'
+ HERMES_E2E_STRICT_ACCEPTANCE: ${{ inputs.strict_acceptance }}
# Machine work dirs (serve.git, transcripts) stay short under runner.temp. The fake
# user profiles live in C:\Users itself, where a real one does: the checkout carries
# 159-character paths, so a deeper profile hits MAX_PATH where no user would (the
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
index e38984d4b83..0e73010e653 100755
--- a/scripts/run_tests.sh
+++ b/scripts/run_tests.sh
@@ -142,6 +142,8 @@ _pf86="$(env | sed -n 's/^ProgramFiles(x86)=//p' | head -n1)"
# the real install.ps1 (it writes HKCU PATH); HERMES_E2E_MACHINE_ROOT,
# HERMES_E2E_PROFILES_ROOT and HERMES_E2E_ARTIFACTS place its fake machines,
# their user profiles and the transcripts CI uploads.
+# * HERMES_E2E_STRICT_ACCEPTANCE makes tests/e2e/core/_pending_fixes.py's
+# known gaps hard failures in an acceptance run (workflow dispatch input).
#
# These are test-infrastructure knobs, not credentials — same class as the
# HERMES_RUN_SLOW_PET_TESTS / HERMES_E2E_BROWSER / HERMES_RUN_E2E opt-ins
@@ -155,7 +157,8 @@ TEST_ENV=()
for _test_var in HERMES_TEST_IMAGE HERMES_TEST_WORKERS HERMES_TEST_PATHS \
HERMES_TEST_FILE_TIMEOUT HERMES_TEST_FILE_RETRIES HERMES_TEST_SLICE \
SSL_CERT_FILE SSL_CERT_DIR HERMES_GATEWAY_LOCK_DIR HERMES_E2E_REQUIRE_TUI CI GITHUB_ACTIONS \
- HERMES_E2E_WINDOWS_INSTALL HERMES_E2E_MACHINE_ROOT HERMES_E2E_PROFILES_ROOT HERMES_E2E_ARTIFACTS; do
+ HERMES_E2E_WINDOWS_INSTALL HERMES_E2E_MACHINE_ROOT HERMES_E2E_PROFILES_ROOT HERMES_E2E_ARTIFACTS \
+ HERMES_E2E_STRICT_ACCEPTANCE; do
if [ -n "${!_test_var:-}" ]; then
TEST_ENV+=("$_test_var=${!_test_var}")
fi
diff --git a/tests/ci/test_pending_fixes_strict.py b/tests/ci/test_pending_fixes_strict.py
new file mode 100644
index 00000000000..b063e68b550
--- /dev/null
+++ b/tests/ci/test_pending_fixes_strict.py
@@ -0,0 +1,95 @@
+"""``known_failure`` under strict acceptance: the gap fails the run instead of XFAILing.
+
+A real pytest process runs a cell whose final assertion is wrapped in ``known_failure``;
+only the environment of that process changes between the cases.
+"""
+
+from __future__ import annotations
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+_REPO = Path(__file__).resolve().parents[2]
+
+_CELL = '''
+from tests.e2e.core._pending_fixes import known_failure, known_gate
+
+GAP = (r"marker survived", "upd-txn: fixed by the batch")
+
+
+def test_gap_still_open():
+ with known_failure(*GAP):
+ assert False, "orphaned_update: marker survived the update"
+
+
+def test_other_failure_is_never_excused():
+ with known_failure(*GAP):
+ assert False, "the update timed out"
+
+
+def test_fixed_gap_passes():
+ with known_failure(*GAP):
+ assert True
+
+
+def test_gate_table_follows_the_same_mode():
+ with known_gate({"cell": GAP}, "cell"):
+ assert False, "marker survived again"
+
+
+def test_gap_another_owner_tracks():
+ with known_failure(r"slow fetch", "#123254: tracked elsewhere"):
+ assert False, "slow fetch downloaded the whole history"
+'''
+
+
+def _run(tmp_path: Path, strict: str | None) -> dict[str, str]:
+ cell = tmp_path / "test_cell.py"
+ cell.write_text(_CELL, encoding="utf-8")
+ env = {k: v for k, v in os.environ.items() if not k.startswith(("PYTEST_", "HERMES_E2E_"))}
+ env["PYTHONPATH"] = str(_REPO)
+ if strict is not None:
+ env["HERMES_E2E_STRICT_ACCEPTANCE"] = strict
+ proc = subprocess.run(
+ [sys.executable, "-m", "pytest", str(cell), "-rA", "-q", "-p", "no:cacheprovider",
+ "-p", "no:randomly", "-o", "addopts=", "--rootdir", str(tmp_path)],
+ cwd=tmp_path, env=env, capture_output=True, text=True, timeout=120)
+ outcomes = {}
+ for line in proc.stdout.splitlines():
+ for verdict in ("PASSED", "FAILED", "XFAIL"):
+ if line.startswith(verdict + " "):
+ outcomes[line.split("::", 1)[1].split()[0]] = verdict
+ assert len(outcomes) == 5, proc.stdout + proc.stderr
+ return outcomes
+
+
[email protected]("strict", [None, "", "0", "other-batch"])
+def test_default_run_xfails_only_the_known_gap(tmp_path, strict):
+ assert _run(tmp_path, strict) == {
+ "test_gap_still_open": "XFAIL",
+ "test_other_failure_is_never_excused": "FAILED",
+ "test_fixed_gap_passes": "PASSED",
+ "test_gate_table_follows_the_same_mode": "XFAIL",
+ "test_gap_another_owner_tracks": "XFAIL",
+ }
+
+
[email protected]("strict", ["upd-txn", "other-batch, upd-txn"])
+def test_strict_acceptance_fails_the_batch_owned_gaps_only(tmp_path, strict):
+ assert _run(tmp_path, strict) == {
+ "test_gap_still_open": "FAILED",
+ "test_other_failure_is_never_excused": "FAILED",
+ "test_fixed_gap_passes": "PASSED",
+ "test_gate_table_follows_the_same_mode": "FAILED",
+ "test_gap_another_owner_tracks": "XFAIL",
+ }
+
+
+def test_strict_acceptance_1_fails_every_known_gap(tmp_path):
+ outcomes = _run(tmp_path, "1")
+ assert outcomes.pop("test_fixed_gap_passes") == "PASSED"
+ assert set(outcomes.values()) == {"FAILED"}
diff --git a/tests/ci/test_update_ci_routing.py b/tests/ci/test_update_ci_routing.py
index 9e293cdd2b9..38e61101f13 100644
--- a/tests/ci/test_update_ci_routing.py
+++ b/tests/ci/test_update_ci_routing.py
@@ -416,3 +416,54 @@ def test_desktop_build_scripts_start_the_desktop_update_suite():
assert "scripts/build/desktop.mjs" in reached, "seed scan broke: the Desktop build runs desktop.mjs"
unowned = sorted(f for f in reached if not cc.classify([f])["e2e_desktop_update"])
assert unowned == []
+
+
+# -- strict acceptance: the dispatch input reaches every E2E suite's environment ------------
+
+_STRICT_STEPS = (
+ (("tests", "e2e"), ".github/workflows/tests.yml", "e2e", "Run e2e tests"),
+ (("tests", "e2e-upgrade"), ".github/workflows/tests.yml", "e2e-upgrade", "Run upgrade e2e tests"),
+ (("tests-os", "e2e-windows"), ".github/workflows/tests-os.yml", "e2e-windows", "Run Windows E2E suite"),
+ (("tests-os", "install-update-e2e", "install-update"), ".github/workflows/windows-install-update-e2e.yml",
+ "install-update", "Run Windows install + update E2E"),
+)
+
+
+def _strict_env(run: dict, path: tuple[str, ...], rel: str, job: str, step_name: str) -> str:
+ node = _reached(run, *path)
+ assert node is not None, f"{'/'.join(path)} did not run"
+ step = next(s for s in _yaml(rel)["jobs"][job]["steps"] if str(s.get("name", "")).startswith(step_name))
+ assert "run_tests.sh" in step["run"]
+ return gha.to_string(gha.render(step["env"]["HERMES_E2E_STRICT_ACCEPTANCE"], node["ctx"]))
+
+
[email protected]("value", ["upd-txn", "1"])
+def test_strict_acceptance_dispatch_reaches_every_e2e_suite(value):
+ """`gh workflow run ci.yaml -f strict_acceptance=upd-txn` (the batch's acceptance run)."""
+ lanes = cc.classify([]) # a dispatch has no diff: every lane on
+ run = _run_workflow(".github/workflows/ci.yaml", inputs={"release": False, "strict_acceptance": value},
+ detect=_detect_outputs(lanes))
+ for path, rel, job, step in _STRICT_STEPS:
+ assert _strict_env(run, path, rel, job, step) == value, "/".join(path)
+
+
+def test_pull_requests_never_run_strict():
+ run = _ci_run(cc.classify([]))
+ for path, rel, job, step in _STRICT_STEPS:
+ assert _strict_env(run, path, rel, job, step) == "", "/".join(path)
+
+
+def test_windows_install_update_dispatch_alone_sets_strict():
+ jobs = _run_workflow(".github/workflows/windows-install-update-e2e.yml",
+ inputs={"strict_acceptance": "upd-txn"})
+ assert _strict_env({"w": {"jobs": jobs}}, ("w", "install-update"),
+ ".github/workflows/windows-install-update-e2e.yml", "install-update",
+ "Run Windows install + update E2E") == "upd-txn"
+ assert "workflow_dispatch" in _on(_yaml(".github/workflows/windows-install-update-e2e.yml"))
+
+
+def test_run_tests_forwards_the_strict_switch():
+ """run_tests.sh starts pytest under `env -i`: an unlisted variable never arrives."""
+ text = (_REPO / "scripts/run_tests.sh").read_text(encoding="utf-8-sig")
+ allow = re.search(r"for _test_var in (.*?); do", text, re.S)
+ assert allow and "HERMES_E2E_STRICT_ACCEPTANCE" in allow.group(1).split()
diff --git a/tests/e2e/core/_pending_fixes.py b/tests/e2e/core/_pending_fixes.py
index 7eabc989b12..9b2e5d25be6 100644
--- a/tests/e2e/core/_pending_fixes.py
+++ b/tests/e2e/core/_pending_fixes.py
@@ -6,16 +6,35 @@ failure message: the cell XFAILs only while it fails exactly that way, fails lou
failure (a timeout, a lost reply, a boot failure), and simply passes once the fix lands, whichever
merges first. Wrap only the final assertions. When a fix has landed, delete its ``known_failure``.
Probe-gated gaps live in ``tests/e2e/core/delivery/_pending_fixes.py``.
+
+Strict acceptance: ``HERMES_E2E_STRICT_ACCEPTANCE`` turns ``known_failure`` blocks into hard
+failures (the gap's own assertion, annotated): ``1`` every block, or a comma list of owners
+(``upd-txn``) for the blocks whose reason starts with ``<owner>:``. Only an acceptance run of an
+integrated batch sets it (the ``strict_acceptance`` dispatch input of ci.yaml /
+windows-install-update-e2e.yml), where an expected failure would accept exactly the gap the
+batch claims to close; gaps other work owns keep their xfail. Never a user setting.
"""
from __future__ import annotations
import contextlib
+import os
import re
from typing import ContextManager, Iterator, Mapping, Tuple, Type
import pytest
+STRICT_ACCEPTANCE_ENV = "HERMES_E2E_STRICT_ACCEPTANCE"
+
+
+def strict_acceptance(reason: str) -> bool:
+ """True when this acceptance run refuses to excuse the gap ``reason`` describes."""
+ value = os.environ.get(STRICT_ACCEPTANCE_ENV, "").strip()
+ if value == "1":
+ return True
+ owners = [o.strip() for o in value.split(",") if o.strip() and o.strip() != "0"]
+ return any(reason.startswith(f"{owner}:") for owner in owners)
+
@contextlib.contextmanager
def known_failure(pattern: str, reason: str,
@@ -29,6 +48,9 @@ def known_failure(pattern: str, reason: str,
except raises as exc:
if not re.search(pattern, str(exc)):
raise
+ if strict_acceptance(reason):
+ exc.add_note(f"{STRICT_ACCEPTANCE_ENV}=1: the known gap is not excused here ({reason})")
+ raise
pytest.xfail(f"{reason} [observed: {str(exc).splitlines()[0][:240]}]")