feat(cfold): canonicalize custom test layout
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
autonomic-bot
2026-06-12 16:08:18 +00:00
parent 87928a9096
commit 44e02425ab
110 changed files with 306 additions and 241 deletions

View File

@ -72,17 +72,16 @@ def test_repo_local_wins_when_approved(tmp_path):
def test_custom_tests_repo_local_gated(tmp_path, monkeypatch):
# custom test_*.py from repo-local only count for approved recipes (HC2); placement rule
# (rcust P4): custom tests live under functional/ (or playwright/) — top-level files are
# lifecycle overlays only, so the repo-local custom here sits in functional/.
# (cfold): custom/ is canonical, while functional/ and playwright/ remain deprecated aliases.
# Use a synthetic recipe name + monkeypatched cc_ci_dir so this is independent of what
# tests/<real-recipe>/ ships (F2-1).
fake_recipe = "ccci-hc2-fixture"
monkeypatch.setattr(discovery, "cc_ci_dir", lambda r: str(tmp_path / "cc-ci" / r))
(tmp_path / "cc-ci" / fake_recipe).mkdir(parents=True)
rl = tmp_path / "repo"
(rl / "functional").mkdir(parents=True)
(rl / "functional" / "test_sso.py").write_text("# repo-local custom\n")
(rl / "functional" / "test_install.py").write_text("# lifecycle name -> excluded from custom\n")
(rl / "custom").mkdir(parents=True)
(rl / "custom" / "test_sso.py").write_text("# repo-local custom\n")
(rl / "custom" / "test_install.py").write_text("# lifecycle name -> excluded from custom\n")
_approve(tmp_path) # not approved -> repo-local custom ignored
assert discovery.custom_tests(fake_recipe, str(rl)) == []
@ -94,6 +93,25 @@ def test_custom_tests_repo_local_gated(tmp_path, monkeypatch):
assert all(os.path.basename(p) != "test_install.py" for _, p in customs)
def test_custom_tests_prefers_custom_and_warns_on_deprecated_aliases(tmp_path, monkeypatch, capsys):
fake_recipe = "ccci-cfold-fixture"
fake_dir = tmp_path / "tests" / fake_recipe
(fake_dir / "custom").mkdir(parents=True)
(fake_dir / "functional").mkdir()
(fake_dir / "playwright").mkdir()
(fake_dir / "custom" / "test_a.py").write_text("# canonical\n")
(fake_dir / "functional" / "test_b.py").write_text("# deprecated alias\n")
(fake_dir / "playwright" / "test_c.py").write_text("# deprecated alias\n")
monkeypatch.setattr(discovery, "cc_ci_dir", lambda r: str(tmp_path / "tests" / r))
customs = discovery.custom_tests(fake_recipe, None)
assert [os.path.basename(path) for _, path in customs] == ["test_a.py", "test_b.py", "test_c.py"]
err = capsys.readouterr().err
assert "deprecated folder 'functional/'" in err
assert "deprecated folder 'playwright/'" in err
def test_install_steps_repo_local_gated(tmp_path):
rl = tmp_path / "repo"
rl.mkdir()