From 0fb382127d3178d236b9fd901a8ca12c5f097b73 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 17 May 2026 18:26:33 -0300 Subject: [PATCH] ci(lesavka): keep test categories canonical --- Cargo.toml | 6 +++--- scripts/ci/hygiene_gate.sh | 10 +++++++--- scripts/ci/test_gate.sh | 18 +++++++++++++++--- .../install/client_install_script_contract.rs | 0 .../install/install_version_path_contract.rs | 0 .../install/server_install_script_contract.rs | 0 .../quality_ratchet_evidence_contract.rs | 4 ++-- tests/test-taxonomy-manifest.json | 8 ++++---- 8 files changed, 31 insertions(+), 15 deletions(-) rename tests/{installer => contract}/scripts/install/client_install_script_contract.rs (100%) rename tests/{installer => contract}/scripts/install/install_version_path_contract.rs (100%) rename tests/{installer => contract}/scripts/install/server_install_script_contract.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index dd96385..29131c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -414,15 +414,15 @@ path = "tests/e2e/server/rct/server_rct_output_probe_e2e_contract.rs" [[test]] name = "client_install_script_contract" -path = "tests/installer/scripts/install/client_install_script_contract.rs" +path = "tests/contract/scripts/install/client_install_script_contract.rs" [[test]] name = "server_install_script_contract" -path = "tests/installer/scripts/install/server_install_script_contract.rs" +path = "tests/contract/scripts/install/server_install_script_contract.rs" [[test]] name = "install_version_path_contract" -path = "tests/installer/scripts/install/install_version_path_contract.rs" +path = "tests/contract/scripts/install/install_version_path_contract.rs" [[test]] name = "relay_proto_integration_contract" diff --git a/scripts/ci/hygiene_gate.sh b/scripts/ci/hygiene_gate.sh index 229eb33..176afa8 100755 --- a/scripts/ci/hygiene_gate.sh +++ b/scripts/ci/hygiene_gate.sh @@ -356,10 +356,10 @@ def testing_contract_violations() -> list[str]: taxonomy_dir = root / 'tests' required_categories = { 'unit', 'component', 'integration', 'api', 'contract', 'e2e', 'system', - 'performance', 'reliability', 'chaos', 'security', 'ui', 'installer', - 'compatibility', 'regression', 'smoke', 'fixtures', 'helpers', 'golden', - 'manual', + 'performance', 'reliability', 'chaos', 'security', 'ui', + 'compatibility', 'regression', 'smoke', 'manual', } + support_categories = {'fixtures', 'helpers', 'golden'} if not taxonomy_dir.exists(): return ['tests: missing repository-level test taxonomy directory'] @@ -370,6 +370,10 @@ def testing_contract_violations() -> list[str]: } for category in sorted(required_categories - present_categories): violations.append(f'tests/{category}: missing standard test category directory') + for category in sorted(present_categories - required_categories - support_categories): + violations.append( + f'tests/{category}: top-level test folders must be a real test category or support data' + ) test_files = [ file diff --git a/scripts/ci/test_gate.sh b/scripts/ci/test_gate.sh index 50dd94b..2ea6b4c 100755 --- a/scripts/ci/test_gate.sh +++ b/scripts/ci/test_gate.sh @@ -78,6 +78,18 @@ counts = {'passed': 0, 'failed': 0, 'ignored': 0, 'measured': 0, 'filtered': 0} test_cases = [] current_target = '' +test_category_names = { + 'api', 'chaos', 'compatibility', 'component', 'contract', 'e2e', + 'integration', 'manual', 'performance', 'regression', 'reliability', + 'security', 'smoke', 'system', 'ui', 'unit', +} +support_category_names = {'fixtures', 'golden', 'helpers'} + +def normalize_category(category: str) -> str: + if category in test_category_names or category in support_category_names: + return category + return 'uncategorized' + manifest_path = pathlib.Path('tests/test-taxonomy-manifest.json') category_by_path = {} category_by_test_name = {} @@ -85,11 +97,11 @@ test_categories = set() if manifest_path.exists(): for item in json.loads(manifest_path.read_text(encoding='utf-8')): path = item.get('new', '') - category = item.get('category', '') + category = normalize_category(item.get('category', '')) if path and category: category_by_path[path] = category category_by_test_name[pathlib.PurePosixPath(path).stem] = category - if category not in {'fixtures', 'golden', 'helpers'}: + if category in test_category_names: test_categories.add(category) def category_for_path(path: str) -> str: @@ -97,7 +109,7 @@ def category_for_path(path: str) -> str: return category_by_path[path] parts = pathlib.PurePosixPath(path).parts if len(parts) >= 2 and parts[0] == 'tests': - return parts[1] + return normalize_category(parts[1]) if path.startswith('src/'): return 'unit' return 'uncategorized' diff --git a/tests/installer/scripts/install/client_install_script_contract.rs b/tests/contract/scripts/install/client_install_script_contract.rs similarity index 100% rename from tests/installer/scripts/install/client_install_script_contract.rs rename to tests/contract/scripts/install/client_install_script_contract.rs diff --git a/tests/installer/scripts/install/install_version_path_contract.rs b/tests/contract/scripts/install/install_version_path_contract.rs similarity index 100% rename from tests/installer/scripts/install/install_version_path_contract.rs rename to tests/contract/scripts/install/install_version_path_contract.rs diff --git a/tests/installer/scripts/install/server_install_script_contract.rs b/tests/contract/scripts/install/server_install_script_contract.rs similarity index 100% rename from tests/installer/scripts/install/server_install_script_contract.rs rename to tests/contract/scripts/install/server_install_script_contract.rs diff --git a/tests/contract/testing/quality_ratchet_evidence_contract.rs b/tests/contract/testing/quality_ratchet_evidence_contract.rs index b1631d9..0a8dcea 100644 --- a/tests/contract/testing/quality_ratchet_evidence_contract.rs +++ b/tests/contract/testing/quality_ratchet_evidence_contract.rs @@ -166,8 +166,8 @@ fn audio_epoch_ui_security_install_and_diagnostics_are_backstopped() { path: "tests/security/server/upstream_media/upstream_media_payload_security_contract.rs", }, EvidencePath { - category: "installer", - path: "tests/installer/scripts/install/install_version_path_contract.rs", + category: "contract", + path: "tests/contract/scripts/install/install_version_path_contract.rs", }, EvidencePath { category: "contract", diff --git a/tests/test-taxonomy-manifest.json b/tests/test-taxonomy-manifest.json index 8850821..3a832aa 100644 --- a/tests/test-taxonomy-manifest.json +++ b/tests/test-taxonomy-manifest.json @@ -40,8 +40,8 @@ "new": "tests/regression/client/input/inputs/client_inputs_toggle_contract.rs" }, { - "category": "installer", - "new": "tests/installer/scripts/install/client_install_script_contract.rs" + "category": "contract", + "new": "tests/contract/scripts/install/client_install_script_contract.rs" }, { "category": "regression", @@ -228,8 +228,8 @@ "new": "tests/regression/server/gadget/server_gadget_recovery_contract.rs" }, { - "category": "installer", - "new": "tests/installer/scripts/install/server_install_script_contract.rs" + "category": "contract", + "new": "tests/contract/scripts/install/server_install_script_contract.rs" }, { "category": "contract",