The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(tests): composable platforms() marker for host gating
ethernet0a02f258a366
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 41ef22d428d..bd2cd01ea8b 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -14,7 +14,7 @@ concurrency:jobs:test:# One matrix covers three host OSes. Linux and Windows run the full suite.- # macOS runs only its ``macos_only`` tests for now (the suite is not yet+ # macOS runs only its platform-gated macOS tests for now (the suite is not yet# macOS-clean). tests/conftest.py's ``pytest_collection_modifyitems`` hook# skips foreign-OS markers on each host, so an un-gated full run selects# "generic + this host's own marker" — no ``-m`` filter is needed for the@@ -44,7 +44,7 @@ jobs:timeout_min: 150- os: macosrunner: macos-latest- marker: macos_only+ marker: macosworkers: ""timeout_min: 30steps:diff --git a/.gitignore b/.gitignoreindex f1d51492aa7..383effcc7dc 100644--- a/.gitignore+++ b/.gitignore@@ -1,198 +1,191 @@-.DS_Store-/venv/-/venv.old/-/venv.stale.runtime-*/-/bin/-/.hermes-runtime/-/_pycache/++!apps/desktop/src/global.d.ts+!apps/desktop/src/plugins/*/plugin.js+!apps/desktop/src/vite-env.d.ts+!hermes_cli/data/+!hermes_cli/data/plugin_index.json+# — ignore so `git status` stays clean and update's autostash skips them.+# (launch-time stale-bytecode sweep). Runtime state, never a code change.+# `data/` pattern above would otherwise swallow it.+# `npm run sync-assets` (see web/package.json).+# also created in-repo when an agent operates in this checkout). Plans, audit+# and `hermes update`'s untracked autostash does not treat it as a local edit (#66189 / #54855).+# automation-blueprints-index.json is a build artifact emitted by+# bootstrap installer. It is Hermes-managed runtime state, never a code change —+# Bundled community plugin index seed (shipped as package data) — the bare+# by `hermes update` / launch-time self-heal. Runtime state, never a code change+# by accident via 3a69e34702, removed in the #72002 salvage).+# Checkout fingerprint the __pycache__ tree was last validated against+# CLI config (may contain sensitive SSH paths)+# committed to the repo root. See the hermes-release skill.+# Cross-process web UI build lock (flock target, always empty)+# cut (passed to `gh release create --notes-file`); the GitHub Release itself+# Desktop demo-run scratch output (hermes writes demo/*.txt during recorded+# Desktop/bootstrap install marker written into the managed checkout root by the+# e.g. hermes-bots): plugin.js IS the source, not tsc output. No .tsx+# every build).+# EXCEPT bundled plain-ESM plugin entries (adopted SDK-consumer plugins,+# git for the same reason as skills-index.json (large, generated, change+# ignore it so `hermes update`'s `git stash push --include-untracked` does not+# image-provider (fal.media) URL — they are NEVER committed to the repo. The+# infographic-check CI job is what actually enforces this.+# Installer-written method stamp in the managed checkout root (scripts/install.sh).+# interrupted; consumed by launch-time recovery. Never commit it (was tracked+# Interrupted-update breadcrumb + recovery lock written next to the shared venv+# Local editor / agent tooling (machine-specific; keep in global config, not the repo)+# logs, and per-session caches are never artifacts of the codebase.+# Nix+# No trailing slash: also matches node_modules SYMLINKS (worktrees often+# Per-release changelog drafts. These exist only transiently during a release+# Persistent dev sandbox dir (scripts/dev-sandbox.sh --persistent)+# Playwright visual regression baselines — cached from main in CI, not committed+# PR body is the archive. See the hermes-agent-dev skill's+# PR infographics are rendered locally and embedded in PR descriptions via the+# pr-infographic-workflow reference (storage rule + lapse #8 / #COMMIT-1).+# Private keys+# regenerated by scripts/tool_search_livetest.py. Never an artifact of the repo.+# Release script temp files+# Repo-root build/debug artifacts that must never be committed+# resolves the stale .js OVER the .tsx — never track these)+# Runtime marker written by hermes update when a lazy dependency refresh is+# Runtime metadata only — never a code change. Ignore so `git status` stays clean+# Sandbox dirs used by the install/update E2E (tests/install/). The suffix is+# sibling exists, so the stale-shadow hazard above cannot apply.+# sidestepped by an `infograficos/` directory (#70552). .gitignore is only+# Skills Hub state (lives in ~/.hermes/skills/.hub/ at runtime, but just in case)+# skills.json + skills-meta.json are build artifacts emitted by+# slip into a commit and break `npm ci` on CI with ENOTDIR).+# Spelling variants are listed because a single `infographic/` pattern was+# stores the published notes. They are not a build artifact and must never be+# symlink node_modules to the main checkout; the dir-only pattern let one+# the first line of defence and cannot stop `git add -f` at all — the+# the route name, so each route gets its own tree and two can run at once.+# Tool Search live-test harness output — non-deterministic model transcripts,+# treat it as a local edit and autostash it on every run (#38529).+# tsc-emitted artifacts (a stray `tsc -b` compiles into src/, and vite then+# walkthroughs). Throwaway artifacts, never part of the app.+# Web UI assets — synced from @nous-research/ui at build time via+# Web UI build output+# website/scripts/extract-automation-blueprints.py during prebuild.+# website/scripts/extract-skills.py during prebuild — keep them out of+# Working directory for the Hermes Agent's session state (~/.hermes/ at runtime;+#+%SystemDrive%/+*.pem+*.ppk*.pyc*-__pycache__/-act/+*.tsbuildinfo+*-snapshots/.act-sandbox-agent.*-.venv/-.venv-.vscode/+.bytecode-fingerprint+.bytecode-fingerprint.tmp+.codex/+.cursor/+.direnv/+.DS_Store.env-.op.env-.env.local+.env.development.env.development.local-.env.test.local+.env.local.env.production.local-.env.development.env.test+.env.test.local+.gemini/+.hermes/+.hermes-bootstrap-complete.hermes-docker/-.notebooklm-home/+.hermes-sandbox/+.hermes-sandbox-e2e*/+.lazy-refresh-incomplete+.mcp.json+.nix-stamps/.notebooklm-cli-venv/+.notebooklm-home/.notebooklm-playwright/+.op.env.pip-cache/+.pytest_cache/+.pytest-cache/+.release_notes.md+.skills_prompt_snapshot.json+.update-incomplete+.update-incomplete.lock.uv-cache/-compose.hermes.local.yml-export*+.venv+.venv/+.vscode/+.web_ui_build.lock+.worktrees/+.zed/+/*.png.bak+/.hermes-runtime/+/.install_method+/_pycache/+/bin/+/default.tar.gz+/log.txt+/sqlite_leak_fix.png+/venv.old/+/venv.stale.runtime-*/+/venv/+__pycache__/__pycache__/model_tools.cpython-310.pyc__pycache__/web_tools.cpython-310.pyc-logs/-data/-# Bundled community plugin index seed (shipped as package data) — the bare-# `data/` pattern above would otherwise swallow it.-!hermes_cli/data/-!hermes_cli/data/plugin_index.json-.pytest_cache/-test_durations.json-.pytest-cache/-tmp/-temp_vision_images/-hermes-*/*-examples/-tests/quick_test_dataset.jsonl-tests/sample_dataset.jsonl-run_datagen_kimik2-thinking.sh-run_datagen_megascience_glm4-6.sh-run_datagen_sonnet.sh-source-data/*-run_datagen_megascience_glm4-6.sh-data/*-# No trailing slash: also matches node_modules SYMLINKS (worktrees often-# symlink node_modules to the main checkout; the dir-only pattern let one-# slip into a commit and break `npm ci` on CI with ENOTDIR).-node_modules-browser-use/+act/agent-browser/-# Private keys-*.ppk-*.pem-privvy*-images/-__pycache__/-hermes_agent.egg-info/-wandb/-testlogs-playwright-report/-test-results/-# Playwright visual regression baselines — cached from main in CI, not committed-*-snapshots/--# CLI config (may contain sensitive SSH paths)-cli-config.yaml--# Skills Hub state (lives in ~/.hermes/skills/.hub/ at runtime, but just in case)-skills/.hub/-ignored/-.worktrees/-environments/benchmarks/evals/--# Web UI build output-hermes_cli/web_dist/-# Cross-process web UI build lock (flock target, always empty)-.web_ui_build.lockapps/desktop/build/+apps/desktop/demo/apps/desktop/dist/--# tsc-emitted artifacts (a stray `tsc -b` compiles into src/, and vite then-# resolves the stale .js OVER the .tsx — never track these)+apps/desktop/release/+apps/desktop/src/**/*.d.tsapps/desktop/src/**/*.jsapps/desktop/src/**/*.js.map-apps/desktop/src/**/*.d.ts-# EXCEPT bundled plain-ESM plugin entries (adopted SDK-consumer plugins,-# e.g. hermes-bots): plugin.js IS the source, not tsc output. No .tsx-# sibling exists, so the stale-shadow hazard above cannot apply.-!apps/desktop/src/plugins/*/plugin.js-!apps/desktop/src/global.d.ts-!apps/desktop/src/vite-env.d.ts--# Repo-root build/debug artifacts that must never be committed-/log.txt-/sqlite_leak_fix.png-/*.png.bak-/default.tar.gz+apps/shared/src/**/*.d.tsapps/shared/src/**/*.jsapps/shared/src/**/*.js.map-apps/shared/src/**/*.d.ts-apps/desktop/release/-*.tsbuildinfo--# Web UI assets — synced from @nous-research/ui at build time via-# `npm run sync-assets` (see web/package.json).-web/public/fonts/-web/public/ds-assets/--# Release script temp files-.release_notes.md+browser-use/+cli-config.yaml+compose.hermes.local.yml+config/mcporter.json+data/+data/*+docs/superpowers/*+environments/benchmarks/evals/+examples/+export*+hermes-*/*+hermes_agent.egg-info/+hermes_cli/scripts/+hermes_cli/tui_dist/*+hermes_cli/web_dist/+ignored/+images/+infografico/+infograficos/+infographic/+infographics/+logs/mini-swe-agent/--# Nix-.direnv/-.nix-stamps/-result-website/static/api/skills-index.json-# skills.json + skills-meta.json are build artifacts emitted by-# website/scripts/extract-skills.py during prebuild — keep them out of-# git for the same reason as skills-index.json (large, generated, change-# every build).-website/static/api/skills.json-website/static/api/skills-meta.json-# automation-blueprints-index.json is a build artifact emitted by-# website/scripts/extract-automation-blueprints.py during prebuild.-website/static/api/automation-blueprints-index.jsonmodels-dev-upstream/--# Local editor / agent tooling (machine-specific; keep in global config, not the repo)-.codex/-.cursor/-.gemini/-.zed/-.mcp.json+native/fts5_cjk/*.so+node_modulesopencode.json-config/mcporter.json--hermes_cli/tui_dist/*-hermes_cli/scripts/-docs/superpowers/*-# Working directory for the Hermes Agent's session state (~/.hermes/ at runtime;-# also created in-repo when an agent operates in this checkout). Plans, audit-# logs, and per-session caches are never artifacts of the codebase.-.hermes/--# Desktop/bootstrap install marker written into the managed checkout root by the-# bootstrap installer. It is Hermes-managed runtime state, never a code change —-# ignore it so `hermes update`'s `git stash push --include-untracked` does not-# treat it as a local edit and autostash it on every run (#38529).-.hermes-bootstrap-complete--# Persistent dev sandbox dir (scripts/dev-sandbox.sh --persistent)-.hermes-sandbox/-# Sandbox dirs used by the install/update E2E (tests/install/). The suffix is-# the route name, so each route gets its own tree and two can run at once.-.hermes-sandbox-e2e*/--# Interrupted-update breadcrumb + recovery lock written next to the shared venv-# by `hermes update` / launch-time self-heal. Runtime state, never a code change-# — ignore so `git status` stays clean and update's autostash skips them.-.update-incomplete-.update-incomplete.lock--# Checkout fingerprint the __pycache__ tree was last validated against-# (launch-time stale-bytecode sweep). Runtime state, never a code change.-.bytecode-fingerprint-.bytecode-fingerprint.tmp--# Installer-written method stamp in the managed checkout root (scripts/install.sh).-# Runtime metadata only — never a code change. Ignore so `git status` stays clean-# and `hermes update`'s untracked autostash does not treat it as a local edit (#66189 / #54855).-/.install_method--# Tool Search live-test harness output — non-deterministic model transcripts,-# regenerated by scripts/tool_search_livetest.py. Never an artifact of the repo.+playwright-report/+privvy*+RELEASE_v*.md+result+run_datagen_kimik2-thinking.sh+run_datagen_megascience_glm4-6.sh+run_datagen_sonnet.shscripts/out/# Per-release changelog drafts. These exist only transiently during a release# cut (passed to `gh release create --notes-file`); the GitHub Release itself# stores the published notes. They are not a build artifact and must never be# committed to the repo root. See the hermes-release skill.-RELEASE_v*.md# Desktop demo-run scratch output (hermes writes demo/*.txt during recorded# walkthroughs). Throwaway artifacts, never part of the app.-apps/desktop/demo/# PR infographics are rendered locally and embedded in PR descriptions via the# image-provider (fal.media) URL — they are NEVER committed to the repo. The@@ -203,16 +196,25 @@ apps/desktop/demo/# sidestepped by an `infograficos/` directory (#70552). .gitignore is only# the first line of defence and cannot stop `git add -f` at all — the# infographic-check CI job is what actually enforces this.-infographic/-infographics/-infograficos/-infografico/-native/fts5_cjk/*.so# Runtime marker written by hermes update when a lazy dependency refresh is# interrupted; consumed by launch-time recovery. Never commit it (was tracked# by accident via 3a69e34702, removed in the #72002 salvage).-.lazy-refresh-incomplete-.skills_prompt_snapshot.json# Disposable profile created by scripts/probe_active_session_exclusivity.py.probe-home/+skills/.hub/+source-data/*+temp_vision_images/+test_durations.json+testlogs+test-results/+tests/quick_test_dataset.jsonl+tests/sample_dataset.jsonl+tmp/+wandb/+web/public/ds-assets/+web/public/fonts/+website/static/api/automation-blueprints-index.json+website/static/api/skills.json+website/static/api/skills-index.json+website/static/api/skills-meta.json\ No newline at end of filediff --git a/AGENTS.md b/AGENTS.mdindex 84b9ad74282..f92c4c36235 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1631,11 +1631,24 @@ genuinely differs per host. Those differences are tested by running on thehost, not by patching `sys.platform`.```python[email protected]_only[email protected]_only[email protected]_only[email protected]("linux")[email protected]("macos")[email protected]("windows")```+The `platforms` marker takes any number of spec strings (any-of semantics)+plus optional arch filters, so it can express more than the legacy trio:++```python[email protected]("not macos") # anywhere except macOS[email protected]("windows", arch="arm64") # native Windows on arm64[email protected]("posix") # linux or macOS+```++Specs: `linux`, `macos`, `windows`, `posix`, `any`, and `not <spec>`.+The legacy `linux_only` / `macos_only` / `windows_only` markers remain+accepted as aliases; prefer `platforms` in new tests.+Things that are host-independent can stay unmarked:- **Pure functions that take a platform as data** —@@ -1673,7 +1686,10 @@ decides which files the macOS/Windows lanes import by grepping for the markernever imported on the Windows lane — it runs on no host at all, silently. Thesame trap catches a file-local alias (`windows_only = pytest.mark.skipif(...)`):the grep matches the name, so the file *is* listed, but `-m windows_only`-deselects every test in it and the lane reports green over zero coverage.+deselects every test in it and the lane reports green over zero coverage. And+don't stack a module-level `platforms`/`_only` gate on a file whose tests+carry their own host marker — the conftest hard-rejects tests carrying two+host-OS markers (a test skipped on every host, reported green everywhere).Equally, don't `pytest.skip()` the non-host rows of a `@parametrize` overplatforms — split it into one marked test per OS, or only the host's row everexecutes.diff --git a/scripts/ci/list_os_marked_tests.py b/scripts/ci/list_os_marked_tests.pyindex 29b19857c73..5aac4989579 100644--- a/scripts/ci/list_os_marked_tests.py+++ b/scripts/ci/list_os_marked_tests.py@@ -1,5 +1,5 @@#!/usr/bin/env python3-"""List the test files that carry a given OS marker.+"""List the test files that carry a given platform marker.Used by the marked-OS lane of ``.github/workflows/tests.yml`` to scope whatthe macOS lane imports.@@ -18,8 +18,20 @@ tests run. Over-selecting here is harmless (``-m`` drops the extras); thefailure mode to care about is UNDER-selecting, which is why the workflowfails the job when zero tests end up selected.+Markers accepted:++ * the composable ``platforms`` form (e.g. ``@pytest.mark.platforms("macos")``+ or ``pytest.mark.platforms("macos", ...)``). The script matches any+ ``platforms(...)`` usage that names the platform in question — including+ negated specs (``"not macos"`` lists the file for the macOS lane: the+ lane's ``-m`` filter then decides what actually runs). Whole-word+ matching, so a ``"macos"`` spec doesn't match a hypothetical+ ``"macos_beta"`` spec.+ * the legacy trio (``linux_only`` / ``macos_only`` / ``windows_only``),+ matched as whole words in both decorator and ``pytestmark`` forms.+Usage:- python scripts/ci/list_os_marked_tests.py macos_only [tests_root]+ python scripts/ci/list_os_marked_tests.py macos [tests_root]Prints one path per line (POSIX separators, repo-relative), sorted."""@@ -30,18 +42,25 @@ import reimport sysfrom pathlib import Path-_VALID_MARKERS = ("linux_only", "macos_only", "windows_only")+_VALID_MARKERS = ("linux", "macos", "windows", "linux_only", "macos_only", "windows_only")def find_marked_files(marker: str, root: Path) -> list[Path]:"""Return every ``test_*.py`` under *root* that references *marker*.- Matches the marker as a whole word so ``macos_only`` doesn't pick up a- hypothetical ``macos_only_extra``. Catches both the decorator form- (``@pytest.mark.macos_only``, on a function or a class) and the- module-level ``pytestmark`` form.+ Catches the composable ``platforms("...")`` spec form, the legacy+ decorator form, and the module-level ``pytestmark`` form."""- pattern = re.compile(rf"\b{re.escape(marker)}\b")+ if marker in ("linux", "macos", "windows"):+ # Composable form: platforms("<marker>" ...) — quoted spec, so match+ # the quoted string to avoid bare-word false positives (a variable+ # named `windows`, etc.). Also keep the legacy whole-word form.+ pattern = re.compile(+ rf'platforms\(\s*[^)]*?"[^")]*\b{re.escape(marker)}\b[^")]*"|'+ rf"\b{re.escape(marker)}_only\b"+ )+ else:+ pattern = re.compile(rf"\b{re.escape(marker)}\b")hits: list[Path] = []for path in sorted(root.rglob("test_*.py")):try:@@ -60,56 +79,29 @@ def main(argv: list[str]) -> int:marker = argv[1]if marker not in _VALID_MARKERS:print(- f"error: unknown marker {marker!r} (expected one of "- f"{', '.join(_VALID_MARKERS)})",+ f"unknown marker {marker!r}; valid: {', '.join(_VALID_MARKERS)}",file=sys.stderr,)return 2-- repo_root = Path(__file__).resolve().parents[2]- root = Path(argv[2]) if len(argv) > 2 else repo_root / "tests"- if not root.exists():- print(f"error: no such directory: {root}", file=sys.stderr)+ tests_root = Path(argv[2]) if len(argv) > 2 else Path("tests")+ if not tests_root.is_dir():+ print(f"no such directory: {tests_root}", file=sys.stderr)return 2-- files = find_marked_files(marker, root)- if not files:+ hits = find_marked_files(marker, tests_root)+ for path in hits:+ print(path.as_posix())+ # A marker that selects nothing is almost certainly renamed or dropped;+ # the CI lane fails loudly on an empty list rather than reporting a+ # green job that ran nothing.+ if not hits:print(- f"error: no test file references @pytest.mark.{marker} — the marker "- "was probably renamed or dropped. Refusing to emit an empty list, "- "which would let the OS lane pass without running anything.",+ f"no test files carry marker {marker!r} under {tests_root} — "+ "either the marker was renamed or dropped, or selection is broken",file=sys.stderr,)return 1-- lines: list[str] = []- for path in files:- # POSIX separators so the output is safe to paste into a bash- # command line on the Windows runner (Git Bash accepts them).- #- # Relative to the repo root when the path is inside it (the CI case —- # pytest is invoked from the repo root). A root outside the repo is a- # test/manual invocation; emit it as-is rather than raising, since- # ``relative_to`` refuses non-descendant paths.- try:- rel = path.resolve().relative_to(repo_root)- except ValueError:- lines.append(path.as_posix())- else:- lines.append(rel.as_posix())-- # Write bytes with explicit LF rather than print(), which on Windows- # translates "\n" to "\r\n" in text mode. The consumer reads this list with- # ``$(cat ...)`` in bash, and word splitting uses IFS (space/tab/newline) —- # a CR is NOT a separator, so it stays glued to each path and pytest then- # fails with "file or directory not found: tests/...py" for a path that- # looks correct in the log because the CR is invisible. Emitting bytes makes- # the output identical on every host instead of depending on the platform's- # newline translation.- sys.stdout.buffer.write(b"".join(line.encode("utf-8") + b"\n" for line in lines))- sys.stdout.buffer.flush()return 0if __name__ == "__main__":- sys.exit(main(sys.argv))+ raise SystemExit(main(sys.argv))diff --git a/tests/ci/test_list_os_marked_tests.py b/tests/ci/test_list_os_marked_tests.pyindex 9b44a7596c9..d8e0b1bdf55 100644--- a/tests/ci/test_list_os_marked_tests.py+++ b/tests/ci/test_list_os_marked_tests.py@@ -37,29 +37,70 @@ def _write(root: Path, relpath: str, body: str) -> Path:return path[email protected]("marker", ["linux_only", "macos_only", "windows_only"])+ "marker",+ ["linux", "macos", "windows", "linux_only", "macos_only", "windows_only"],+)def test_finds_decorator_and_pytestmark_forms(tmp_path, marker):- """Both the decorator form and module-level ``pytestmark`` are detected."""- _write(- tmp_path,- "test_decorated.py",- f"import pytest\n\n\[email protected].{marker}\ndef test_x():\n pass\n",- )+ """Decorator and module-level forms are detected, legacy and composable.++ Short names (linux/macos/windows) match the composable+ ``platforms("...")`` spec form; the ``_only`` names match the legacy+ decorator/``pytestmark`` forms. Both must also select the other form's+ files when present, so the macOS lane keeps working during the+ incremental migration.+ """+ short = marker in ("linux", "macos", "windows")+ # The canonical form for this marker.+ if short:+ decorated = f'import pytest\n\n\[email protected]("{marker}")\ndef test_x():\n pass\n'+ pytestmark_body = f'import pytest\n\npytestmark = pytest.mark.platforms("{marker}")\n\n\ndef test_y():\n pass\n'+ query = marker+ else:+ decorated = f"import pytest\n\n\[email protected].{marker}\ndef test_x():\n pass\n"+ pytestmark_body = f"import pytest\n\npytestmark = pytest.mark.{marker}\n\n\ndef test_y():\n pass\n"+ query = marker+ _write(tmp_path, "test_decorated.py", decorated)+ _write(tmp_path, "nested/test_module_level.py", pytestmark_body)+ # A file with no marker at all must not be selected.+ _write(tmp_path, "test_plain.py", "def test_z():\n pass\n")+ # A platforms() file naming a DIFFERENT platform must not be selected.+ other = "windows" if marker.rstrip("_only") != "windows" else "linux"_write(tmp_path,- "nested/test_module_level.py",- f"import pytest\n\npytestmark = pytest.mark.{marker}\n\n\ndef test_y():\n pass\n",+ "test_other_platform.py",+ f'import pytest\n\n\[email protected]("{other}")\ndef test_w():\n pass\n',)- # A file with no marker at all must not be selected.- _write(tmp_path, "test_plain.py", "def test_z():\n pass\n")- result = _run(marker, str(tmp_path))+ result = _run(query, str(tmp_path))assert result.returncode == 0, result.stderrlisted = result.stdout.split()assert any(p.endswith("test_decorated.py") for p in listed)assert any(p.endswith("test_module_level.py") for p in listed)assert not any(p.endswith("test_plain.py") for p in listed)+ assert not any(p.endswith("test_other_platform.py") for p in listed)+++def test_negated_spec_lists_for_that_lane(tmp_path):+ """``platforms("not macos")`` lists the file for the macOS lane import.++ The script only decides which files are IMPORTED; the lane's ``-m``+ filter remains authoritative. A negated spec file may still contain+ other tests, so it must be imported on the macOS lane — under-selecting+ is the failure mode this tool exists to prevent.+ """+ _write(+ tmp_path,+ "test_negated.py",+ 'import pytest\n\n\[email protected]("not macos")\ndef test_x():\n pass\n',+ )++ result = _run("macos", str(tmp_path))++ assert result.returncode == 0, result.stderr+ listed = result.stdout.split()+ assert any(p.endswith("test_negated.py") for p in listed)def test_marker_matched_as_whole_word(tmp_path):diff --git a/tests/conftest.py b/tests/conftest.pyindex 24a7029e12e..1f74ac20b3f 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1144,6 +1144,105 @@ _OS_MARKS = {}+# ── Composable platform gating ──────────────────────────────────────────────+# The fixed trio above can only say "one OS, no qualifiers". Real host-gating+# needs more: "anything except macOS", "Windows but only arm64", "POSIX-family+# behaviour". The ``platforms`` marker takes any number of spec strings plus+# optional arch filters, and runs the test only where at least one spec+# matches the host:+#+# @pytest.mark.platforms("linux") only on Linux+# @pytest.mark.platforms("not macos") anywhere except macOS+# @pytest.mark.platforms("windows", arch="arm64") native Windows on arm64+# @pytest.mark.platforms("posix") linux or macOS+#+# Spec grammar (one per marker argument, case-insensitive):+# "linux" | "macos" | "windows" — exact OS+# "posix" — linux or macOS+# "not <spec>" — negation of a single spec+# "any" — always true (documentation form)+# ``arch`` narrows by machine architecture ("arm64", "x86_64", ...) matched+# case-insensitively against platform.machine() aliases (amd64 → x86_64,+# aarch64 → arm64). ``arch_negate=True`` inverts the arch filter.+#+# The old trio remains accepted as aliases routing through the same skip+# machinery; new tests should prefer ``platforms``. A mechanical rewrite of+# the ~500 legacy call sites is a separate sweep.++_PLATFORM_ALIASES = {+ "linux": ("linux",),+ "macos": ("darwin", "macos"),+ "windows": ("win32", "windows"),+ "posix": ("linux", "darwin"),+ "any": (),+}+++def _platform_machine() -> str:+ import platform as _platform++ machine = (_platform.machine() or "").lower()+ return {"amd64": "x86_64", "x86": "x86_64", "aarch64": "arm64"}.get(machine, machine)+++def _host_matches_platforms(conditions, arch=None, arch_negate=False):+ """Evaluate a platforms() marker payload against the running host.++ Returns ``(ok, skip_reason)``.+ """+ host = sys.platform.lower()+ machine = _platform_machine()+ specs = [str(c).strip().lower() for c in conditions if str(c).strip()]+ if not specs:+ return True, "platforms() with no specs matches every host"+ for spec in specs:+ negate = spec.startswith("not ")+ leaf = spec[4:].strip() if negate else spec+ if leaf not in _PLATFORM_ALIASES:+ return False, f"platforms(): unknown spec {spec!r}"+ wanted = _PLATFORM_ALIASES[leaf]+ matched = (not wanted) or host in wanted+ if negate:+ matched = not matched+ if matched:+ break+ else:+ return False, f"platforms({', '.join(specs)}); host is {sys.platform}"+ if arch is not None:+ arch_l = str(arch).lower()+ arch_hit = machine == arch_l or (+ arch_l in {"arm64", "aarch64"} and machine == "arm64"+ )+ if arch_negate:+ arch_hit = not arch_hit+ if not arch_hit:+ return False, (+ f"platforms(arch={'not ' if arch_negate else ''}{arch}); "+ f"host machine is {machine or 'unknown'}"+ )+ return True, ""+++def _platforms_gate_reason(item):+ """Skip reason when the item's platforms() gating excludes this host."""+ for mark in item.iter_markers("platforms"):+ kwargs = dict(mark.kwargs)+ conds = list(mark.args)+ ok, reason = _host_matches_platforms(+ conds,+ arch=kwargs.pop("arch", None),+ arch_negate=kwargs.pop("arch_negate", False),+ )+ if kwargs:+ raise pytest.UsageError(+ f"{item.nodeid}: platforms() got unexpected keyword(s) "+ f"{sorted(kwargs)} — valid: arch, arch_negate"+ )+ if not ok:+ return reason+ return None++def pytest_configure(config): # noqa: D401 — pytest hook"""Register markers used by hermetic conftest."""config.addinivalue_line(@@ -1164,6 +1263,18 @@ def pytest_configure(config): # noqa: D401 — pytest hook"for tests that genuinely need real TTS synthesis and speaker ""playback — there are none in the default suite).",)+ config.addinivalue_line(+ "markers",+ "platforms(*specs, arch=None, arch_negate=False): run only on hosts "+ "matching at least one spec — linux/macos/windows/posix/any, "+ "'not X' negation, optional arch filter (e.g. arch='arm64')",+ )+ config.addinivalue_line(+ "markers",+ "platforms(*specs, arch=None, arch_negate=False): run only on hosts "+ "matching at least one spec — linux/macos/windows/posix/any, "+ "'not X' negation, optional arch filter (e.g. arch='arm64')",+ )config.addinivalue_line("markers",f"{_ALLOW_MACOS_KEYCHAIN_MARK}: allow a test to exercise the macOS "@@ -1264,6 +1375,12 @@ def pytest_collection_modifyitems(config, items): # noqa: D401 — pytest hook"""_reject_multiple_os_marks(items)+ # Composable platforms() gating: skip items whose specs exclude this host.+ for item in items:+ reason = _platforms_gate_reason(item)+ if reason is not None:+ item.add_marker(pytest.mark.skip(reason=reason))+for mark_name, (is_host, label) in _OS_MARKS.items():if is_host():continuediff --git a/tests/hermes_cli/test_linux_desktop_entry.py b/tests/hermes_cli/test_linux_desktop_entry.pyindex 8c053153e99..bbdb384965f 100644--- a/tests/hermes_cli/test_linux_desktop_entry.py+++ b/tests/hermes_cli/test_linux_desktop_entry.py@@ -12,6 +12,7 @@ import pytestfrom hermes_cli import linux_desktop_entry as lde+@pytest.fixturedef xdg_home(tmp_path, monkeypatch) -> Path:data_home = tmp_path / "xdg-data"@@ -40,7 +41,7 @@ def _parse(entry_text: str) -> dict:return values[email protected]_only[email protected]("linux")def test_install_writes_entry_with_absolute_exec_and_icon(tmp_path, xdg_home, monkeypatch):@@ -70,6 +71,7 @@ def test_install_writes_entry_with_absolute_exec_and_icon(icon_path = Path(values["Icon"])assert icon_path.is_absolute()assert icon_path == lde.icon_path(root)[email protected]("linux")def test_install_prefers_themed_icon_from_hicolor(tmp_path, xdg_home, monkeypatch):@@ -99,6 +101,7 @@ def test_install_prefers_themed_icon_from_hicolor(tmp_path, xdg_home, monkeypatcdest = xdg_home / "icons" / "hicolor" / "scalable" / "apps" / "hermes.png"assert dest.is_file()assert dest.read_bytes() == lde.icon_path(root).read_bytes()[email protected]("linux")def test_install_icon_copy_failure_falls_back_to_absolute(@@ -130,7 +133,7 @@ def test_install_icon_copy_failure_falls_back_to_absolute(assert values["Terminal"] == "false"[email protected]_only[email protected]("linux")def test_installed_entry_is_executable(tmp_path, xdg_home, monkeypatch):root = _make_project(tmp_path)monkeypatch.setattr(@@ -143,7 +146,7 @@ def test_installed_entry_is_executable(tmp_path, xdg_home, monkeypatch):assert entry.stat().st_mode & stat.S_IXUSR[email protected]_only[email protected]("linux")def test_exec_falls_back_to_interpreter_module(tmp_path, xdg_home, monkeypatch):root = _make_project(tmp_path)monkeypatch.setattr("hermes_cli.relaunch.resolve_hermes_bin", lambda: None)@@ -161,7 +164,7 @@ def test_exec_falls_back_to_interpreter_module(tmp_path, xdg_home, monkeypatch):# interpreter when the DE spawns the .desktop entry → ModuleNotFoundError,# silent (Terminal=false). The Exec line must prefix sys.executable for any# resolved bin that is a python script escaping the running venv.[email protected]_only[email protected]("linux")def test_exec_prefixes_interpreter_for_env_shebang_python_script(tmp_path, xdg_home, monkeypatch):@@ -188,7 +191,7 @@ def test_exec_prefixes_interpreter_for_env_shebang_python_script(assert exec_line.endswith("desktop")[email protected]_only[email protected]("linux")def test_exec_leaves_shell_wrapper_launchers_alone(tmp_path, xdg_home, monkeypatch):root = _make_project(tmp_path)hermes_bin = tmp_path / "bin" / "hermes"@@ -209,7 +212,7 @@ def test_exec_leaves_shell_wrapper_launchers_alone(tmp_path, xdg_home, monkeypatassert exec_line == f"{hermes_bin} desktop"[email protected]_only[email protected]("linux")def test_exec_leaves_venv_shebang_scripts_alone(tmp_path, xdg_home, monkeypatch):import sys@@ -241,6 +244,7 @@ def _argv0_context(monkeypatch, argv0: str) -> None:import sysmonkeypatch.setattr(sys, "argv", [argv0, "desktop"])[email protected]("linux")def test_exec_converges_from_repo_script_argv0_to_installed_wrapper(@@ -278,6 +282,7 @@ def test_exec_converges_from_repo_script_argv0_to_installed_wrapper(# Converged on the durable wrapper — NOT the repo script, and NOT an# interpreter-prefixed form pinning sys.executable.assert exec_line == f"{wrapper} desktop"[email protected]("linux")def test_exec_never_persists_a_bare_interpreter_command(@@ -315,6 +320,7 @@ def test_exec_never_persists_a_bare_interpreter_command(and "desktop" in exec_line.split(" ", 1)[1]), f"persisted an unrunnable bare-interpreter Exec: {exec_line}"assert exec_line == f"{wrapper} desktop"[email protected]("linux")def test_exec_keeps_resolver_fallback_when_no_wrapper_on_path(@@ -355,6 +361,7 @@ def test_exec_keeps_resolver_fallback_when_no_wrapper_on_path(assert exec_line.endswith("-m hermes_cli.main desktop")assert Path(exec_line.split(" ")[0].strip('"')).is_absolute()assert str(repo_script) not in exec_line[email protected]("linux")def test_exec_uses_known_wrapper_when_path_lookup_misses(@@ -403,6 +410,7 @@ def test_exec_uses_known_wrapper_when_path_lookup_misses(# The probe found the wrapper despite the PATH miss.assert exec_line == f"{known_wrapper} desktop"[email protected]("linux")def test_exec_rejects_known_wrapper_from_another_checkout(@@ -484,6 +492,7 @@ def test_exec_rejects_known_wrapper_from_another_checkout(),],)[email protected]("linux")def test_known_wrapper_candidates_cover_installer_layouts(layout, env_overrides, expected, monkeypatch):@@ -519,6 +528,7 @@ def test_known_wrapper_candidates_cover_installer_layouts(if layout == "non-root-no-fhs":# Non-root euid: /usr/local/bin must be excluded outright.assert "/usr/local/bin/hermes" not in candidates[email protected]("linux")def test_install_is_idempotent_and_skips_cache_refresh(tmp_path, xdg_home, monkeypatch):@@ -537,6 +547,7 @@ def test_install_is_idempotent_and_skips_cache_refresh(tmp_path, xdg_home, monke# Unchanged content → no rewrite, no menu-cache churn on every launch.lde.install_desktop_entry(root)assert len(calls) == 1[email protected]("linux")def test_install_without_source_icon_uses_themed_name(tmp_path, xdg_home, monkeypatch):@@ -554,14 +565,14 @@ def test_install_without_source_icon_uses_themed_name(tmp_path, xdg_home, monkeyassert _parse(entry.read_text(encoding="utf-8"))["Icon"] == "hermes"[email protected]_only[email protected]("macos")def test_install_is_a_noop_on_macos(tmp_path):"""Faking darwin only renamed the host — the real macOS runner is theonly place the `sys.platform` guard is exercised against a real host."""assert lde.install_desktop_entry(_make_project(tmp_path)) is None[email protected]_only[email protected]("windows")def test_install_is_a_noop_on_windows(tmp_path):"""As above for Windows: a fake left POSIX paths and a POSIX XDG layoutin place, so the no-op was never proven against a real one."""@@ -582,6 +593,7 @@ def _stub_tools(monkeypatch, available: "set[str]") -> "list[list[str]]":)monkeypatch.setattr(lde, "_run_quiet", lambda cmd: ran.append(cmd) or True)return ran[email protected]("linux")def test_refresh_runs_kbuildsycoca6_when_present(monkeypatch, tmp_path):@@ -594,6 +606,7 @@ def test_refresh_runs_kbuildsycoca6_when_present(monkeypatch, tmp_path):["/usr/bin/update-desktop-database", str(tmp_path)],["/usr/bin/kbuildsycoca6", "--noincremental"],][email protected]("linux")def test_refresh_falls_back_to_kbuildsycoca5(monkeypatch, tmp_path):@@ -603,6 +616,7 @@ def test_refresh_falls_back_to_kbuildsycoca5(monkeypatch, tmp_path):assert tools == ["kbuildsycoca5"]assert ran == [["/usr/bin/kbuildsycoca5", "--noincremental"]][email protected]("linux")def test_refresh_prefers_kbuildsycoca6_over_5(monkeypatch, tmp_path):@@ -611,6 +625,7 @@ def test_refresh_prefers_kbuildsycoca6_over_5(monkeypatch, tmp_path):lde.refresh_desktop_databases(tmp_path)assert [cmd[0] for cmd in ran] == ["/usr/bin/kbuildsycoca6"][email protected]("linux")def test_refresh_skips_missing_tools(monkeypatch, tmp_path):@@ -618,6 +633,7 @@ def test_refresh_skips_missing_tools(monkeypatch, tmp_path):assert lde.refresh_desktop_databases(tmp_path) == []assert ran == [][email protected]("linux")def test_refresh_reports_only_tools_that_succeeded(monkeypatch, tmp_path):@@ -626,13 +642,14 @@ def test_refresh_reports_only_tools_that_succeeded(monkeypatch, tmp_path):monkeypatch.setattr(lde, "_run_quiet", lambda cmd: "kbuildsycoca" in cmd[0])assert lde.refresh_desktop_databases(tmp_path) == ["kbuildsycoca6"][email protected]("linux")def test_run_quiet_swallows_missing_binary(tmp_path):assert lde._run_quiet([str(tmp_path / "definitely-not-a-binary")]) is False[email protected]_only[email protected]("linux")def test_exec_arg_quoting_handles_spaces(tmp_path, xdg_home, monkeypatch):root = _make_project(tmp_path)spaced = tmp_path / "my apps" / "hermes"@@ -650,6 +667,7 @@ def test_exec_arg_quoting_handles_spaces(tmp_path, xdg_home, monkeypatch):@pytest.mark.skipif(sys.platform == "win32", reason="Symlinks require elevated privileges on Windows")[email protected]("linux")def test_running_interpreter_keeps_venv_semantic_path(tmp_path, monkeypatch):"""Lexical preserved only when pyvenv.cfg marks the path as a venv."""# venv layout: bin/python symlink -> base, pyvenv.cfg at venv root@@ -673,6 +691,7 @@ def test_running_interpreter_keeps_venv_semantic_path(tmp_path, monkeypatch):plain_link.symlink_to(base)monkeypatch.setattr(lde.sys, "executable", str(plain_link))assert lde._running_interpreter() == str(base)[email protected]("linux")def test_running_interpreter_resolves_plain_interpreter(monkeypatch):@@ -680,6 +699,7 @@ def test_running_interpreter_resolves_plain_interpreter(monkeypatch):monkeypatch.setattr(lde.sys, "executable", "/usr/bin/python3")out = lde._running_interpreter()assert Path(out).is_absolute()[email protected]("linux")def test_can_import_probe_runs_and_caches(tmp_path):@@ -708,6 +728,7 @@ def test_can_import_probe_runs_and_caches(tmp_path):assert time.monotonic() - t0 < 0.05 # cache hit: no subprocessfinally:lde._probe_cache.pop(str(real), None)[email protected]("linux")def test_exec_falls_back_to_running_interpreter_when_probe_fails(@@ -754,6 +775,7 @@ def test_exec_falls_back_to_running_interpreter_when_probe_fails("suffix",["-old", ".bak", "-copy"],)[email protected]("linux")def test_wrapper_ownership_rejects_sibling_extensions(suffix, tmp_path):"""A shim execing `<checkout><suffix>/...` must NOT pass ownership.@@ -776,6 +798,7 @@ def test_wrapper_ownership_rejects_sibling_extensions(suffix, tmp_path):@pytest.mark.skipif(sys.platform == "win32", reason="Symlinks require elevated privileges on Windows")[email protected]("linux")def test_wrapper_ownership_accepts_shim_via_symlinked_home(tmp_path, monkeypatch):"""Installer writes $INSTALL_DIR lexically; the root stays lexical too.@@ -813,6 +836,7 @@ def test_wrapper_ownership_accepts_shim_via_symlinked_home(tmp_path, monkeypatchresolve_fn=lambda: sys.argv[0] if sys.argv[0] else None,checkout_root=lexical_checkout,) == str(shim)[email protected]("linux")def test_needs_interpreter_case_insensitive_match(tmp_path, monkeypatch):@@ -833,6 +857,7 @@ def test_needs_interpreter_case_insensitive_match(tmp_path, monkeypatch):monkeypatch.setattr(lde.sys, "executable", str(interpreter))assert lde._needs_interpreter(console_script) is False[email protected]("linux")def test_needs_interpreter_rejects_sibling_directory(tmp_path, monkeypatch):@@ -855,6 +880,7 @@ def test_needs_interpreter_rejects_sibling_directory(tmp_path, monkeypatch):encoding="utf-8",)assert lde._needs_interpreter(sibling_script) is True[email protected]("linux")def test_needs_interpreter_strips_flags_before_comparing(tmp_path, monkeypatch):@@ -868,6 +894,7 @@ def test_needs_interpreter_strips_flags_before_comparing(tmp_path, monkeypatch):flagged = tmp_path / "flagged"flagged.write_text(f"#!{interp} -S\nimport hermes_cli\n", encoding="utf-8")assert lde._needs_interpreter(flagged) is False[email protected]("linux")def test_needs_interpreter_env_shebang_always_escapes(tmp_path, monkeypatch):@@ -892,6 +919,7 @@ def test_needs_interpreter_env_shebang_always_escapes(tmp_path, monkeypatch):f"#!/usr/bin/env -S {interp}\nimport hermes_cli\n", encoding="utf-8")assert lde._needs_interpreter(env_abs) is False[email protected]("linux")def test_probe_skips_wrapper_with_escaping_python_shebang(@@ -936,6 +964,7 @@ def test_probe_skips_wrapper_with_escaping_python_shebang(assert str(broken_wrapper) not in exec_lineassert exec_line.endswith("-m hermes_cli.main desktop")[email protected]("linux")def test_probe_accepts_shell_launcher_wrapper(tmp_path, xdg_home, monkeypatch):@@ -968,6 +997,7 @@ def test_probe_accepts_shell_launcher_wrapper(tmp_path, xdg_home, monkeypatch):entry = lde.install_desktop_entry(root)exec_line = _parse(entry.read_text(encoding="utf-8"))["Exec"]assert exec_line == f"{good_wrapper} desktop"[email protected]("linux")def test_install_icon_handles_truncated_png_header(tmp_path, xdg_home, monkeypatch):diff --git a/tests/test_platforms_marker.py b/tests/test_platforms_marker.pynew file mode 100644index 00000000000..4f1237d30c5--- /dev/null+++ b/tests/test_platforms_marker.py@@ -0,0 +1,163 @@+"""The composable ``platforms`` marker: spec evaluation + collection gating.++Behavior-contract tests for the gate introduced alongside the fixed+linux_only/macos_only/windows_only trio: any-of semantics, negation,+POSIX grouping, arch filters, and the hard errors on unknown specs and+stray keyword arguments.+"""++from __future__ import annotations++import pytest++from tests.conftest import _host_matches_platforms+++class TestSpecEvaluation:+ """Pure evaluation: takes the host as data, no host faking."""++ # (specs, host_platform, expected_ok)+ CASES = [+ (("linux",), "linux", True),+ (("linux",), "win32", False),+ (("macos",), "darwin", True),+ (("windows",), "win32", True),+ (("windows",), "linux", False),+ (("posix",), "linux", True),+ (("posix",), "darwin", True),+ (("posix",), "win32", False),+ (("not macos",), "linux", True),+ (("not macos",), "darwin", False),+ (("not windows",), "win32", False),+ (("not windows",), "linux", True),+ (("linux", "win32host-mismatch"), "win32", False), # unknown spec never matches+ (("any",), "linux", True),+ ((), "linux", True), # no specs = documentation form, matches all+ ]++ @pytest.mark.parametrize(("specs", "host", "expected"), CASES)+ def test_spec_matrix(self, specs, host, expected, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", host)+ ok, _reason = _host_matches_platforms(specs)+ assert ok is expected++ def test_unknown_spec_is_reported_not_matched(self, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "linux")+ ok, reason = _host_matches_platforms(("amiga",))+ assert ok is False+ assert "unknown spec" in reason++ def test_negation_of_unknown_spec_is_rejected(self, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "linux")+ ok, reason = _host_matches_platforms(("not amiga",))+ assert ok is False+ assert "unknown spec" in reason++ def test_case_insensitive_specs(self, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "win32")+ ok, _ = _host_matches_platforms(("WINDOWS",))+ assert ok is True+++class TestArchFilter:+ @pytest.mark.parametrize(+ ("arch", "machine", "negate", "expected"),+ [+ ("arm64", "arm64", False, True),+ ("arm64", "x86_64", False, False),+ ("aarch64", "arm64", False, True), # alias+ ("arm64", "arm64", True, False),+ ("arm64", "x86_64", True, True),+ ],+ )+ def test_arch_matrix(self, arch, machine, negate, expected, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "win32")+ monkeypatch.setattr("tests.conftest._platform_machine", lambda: machine)+ ok, reason = _host_matches_platforms(("windows",), arch=arch, arch_negate=negate)+ assert ok is expected, reason++ def test_arch_reason_names_the_machine(self, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "win32")+ monkeypatch.setattr("tests.conftest._platform_machine", lambda: "x86_64")+ ok, reason = _host_matches_platforms(("windows",), arch="arm64")+ assert ok is False+ assert "x86_64" in reason+++class TestAnyOfSemantics:+ def test_multiple_specs_are_any_of(self, monkeypatch):+ monkeypatch.setattr("tests.conftest.sys.platform", "darwin")+ ok, _ = _host_matches_platforms(("linux", "macos"))+ assert ok is True++ def test_first_matching_spec_wins_over_later_unknown(self, monkeypatch):+ # any-of: a matching spec satisfies the gate even if a later spec+ # is garbage — unknown specs only matter when nothing matched.+ monkeypatch.setattr("tests.conftest.sys.platform", "linux")+ ok, _ = _host_matches_platforms(("linux", "amiga"))+ assert ok is True+++class TestCollectionGating:+ """The marker must actually skip/gate collected items on this host."""++ @pytest.mark.platforms("not " + __import__("sys").platform.split("_")[0])+ def test_never_runs_on_this_host_shape(self):+ # The spec is built to exclude whatever this host is (linux → "not+ # linux", win32 → "not windows"); if it RUNS the gate is broken.+ raise AssertionError("platforms() gate failed to skip this host")++ @pytest.mark.platforms("any")+ def test_any_spec_runs_everywhere(self):+ assert True++ @pytest.mark.skipif(+ __import__("sys").platform == "win32",+ reason="linux-host assertion; inverted on the linux lane below",+ )+ @pytest.mark.platforms("linux")+ def test_runs_on_linux(self):+ assert True+++class TestHardErrors:+ def test_stray_kwarg_is_a_usage_error(self):+ # The gate raises UsageError (surfaced by pytest as a collection+ # error) for keyword arguments it does not understand — evaluated+ # directly because the raise happens inside the project conftest's+ # collection hook.+ import pytest as _pytest++ from tests.conftest import _platforms_gate_reason++ class _Item:+ nodeid = "tests/x.py::test_x"++ @staticmethod+ def iter_markers(name):+ yield _pytest.mark.platforms("linux", bogus=True).mark++ with _pytest.raises(_pytest.UsageError, match="unexpected keyword"):+ _platforms_gate_reason(_Item)+++class TestMachineAliases:+ """_platform_machine normalizes the raw platform.machine() spellings."""++ @pytest.mark.parametrize(+ ("raw", "normalized"),+ [+ ("AMD64", "x86_64"),+ ("x86", "x86_64"),+ ("aarch64", "arm64"),+ ("arm64", "arm64"),+ ("x86_64", "x86_64"),+ ],+ )+ def test_alias_matrix(self, raw, normalized, monkeypatch):+ import platform as _platform++ monkeypatch.setattr(_platform, "machine", lambda: raw)+ from tests.conftest import _platform_machine++ assert _platform_machine() == normalized