Last active
July 14, 2026 02:08
-
-
Save jasonLaster/179b6b4544cb2551e7565aa3e6c785c5 to your computer and use it in GitHub Desktop.
Mechanical refactor transform: mirror environment tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Reproduce the environment test layout move.""" | |
| import sys | |
| from pathlib import Path | |
| sys.path.append(".claude/skills/mechanical-refactor-verify") | |
| from mechanical_refactor_verify_utils import git_add_and_commit, verify_mechanical_refactor | |
| BASE_COMMIT = "23eb002571d220f3d06150d2fcdc4a727c4383a3" | |
| TARGET_COMMIT = "6ca4dbc0d52b3b1afede003cb07a695937095a2f" | |
| def _replace(path: Path, old: str, new: str) -> None: | |
| content = path.read_text() | |
| updated = content.replace(old, new) | |
| if updated == content: | |
| raise RuntimeError(f"replacement not found in {path}: {old!r}") | |
| path.write_text(updated) | |
| def transform(dir_root: Path) -> None: | |
| """Move environment tests and update references.""" | |
| moves = { | |
| "autonomy/tests/test_podman_provider.py": "autonomy/tests/env_providers/test_podman_provider.py", | |
| "autonomy/tests/math_verifier_report.txt": "autonomy/tests/envs/math_verifier_report.txt", | |
| "autonomy/tests/math_verifier_test_data.json": "autonomy/tests/envs/math_verifier_test_data.json", | |
| "autonomy/tests/test_pydantic_typing.py": "autonomy/tests/envs/test_coding_metadata_validation.py", | |
| "autonomy/tests/test_harbor_env.py": "autonomy/tests/envs/test_harbor_env.py", | |
| "autonomy/tests/test_math_verifier.py": "autonomy/tests/envs/test_math_env.py", | |
| "autonomy/tests/test_nova_act_env.py": "autonomy/tests/envs/test_nova_act_env_pool.py", | |
| "autonomy/tests/test_oss_nova_act_env.py": "autonomy/tests/envs/test_oss_nova_act_env.py", | |
| "autonomy/tests/test_parsing_assertions.py": "autonomy/tests/envs/test_oss_nova_act_parsing.py", | |
| "autonomy/tests/test_verifier_env_dispatch.py": "autonomy/tests/envs/test_verifier_env_dispatch.py", | |
| "autonomy/tests/test_verifier_utils.py": "autonomy/tests/envs/test_verifier_utils.py", | |
| "autonomy/tests/local_provider.py": "autonomy/tests/fixtures/local_provider.py", | |
| } | |
| for source_name, target_name in moves.items(): | |
| source = dir_root / source_name | |
| target = dir_root / target_name | |
| target.parent.mkdir(parents=True, exist_ok=True) | |
| source.rename(target) | |
| local_provider_import = "from autonomy.tests.local_provider import LocalProvider" | |
| fixture_provider_import = "from autonomy.tests.fixtures.local_provider import LocalProvider" | |
| for relative_path in ( | |
| "autonomy/README_CLAUDE.md", | |
| "autonomy/tests/env_providers/test_service_endpoints.py", | |
| "autonomy/tests/envs/test_coding_metadata_validation.py", | |
| "autonomy/tests/envs/test_verifier_utils.py", | |
| "autonomy/tests/fixtures/local_provider.py", | |
| "autonomy/tests/utils/test_code_verifier.py", | |
| "autonomy/tests/utils/test_code_verifier_sample.py", | |
| ): | |
| _replace(dir_root / relative_path, local_provider_import, fixture_provider_import) | |
| for relative_path in ( | |
| "autonomy/tests/envs/test_coding_metadata_validation.py", | |
| "autonomy/tests/envs/test_math_env.py", | |
| "autonomy/tests/envs/test_verifier_utils.py", | |
| ): | |
| _replace( | |
| dir_root / relative_path, | |
| "slime_root = Path(__file__).parent.parent.parent.parent", | |
| "slime_root = Path(__file__).parent.parent.parent.parent.parent", | |
| ) | |
| _replace( | |
| dir_root / "autonomy/tests/envs/test_harbor_env.py", | |
| "autonomy/tests/test_harbor_env.py", | |
| "autonomy/tests/envs/test_harbor_env.py", | |
| ) | |
| _replace( | |
| dir_root / "autonomy/tests/fixtures/local_provider.py", | |
| "intentionally placed in autonomy/tests/ to prevent", | |
| "intentionally placed in autonomy/tests/fixtures/ to prevent", | |
| ) | |
| _replace( | |
| dir_root / "autonomy/tests/run_tests.sh", | |
| "autonomy/tests/test_verifier_utils.py", | |
| "autonomy/tests/envs/test_verifier_utils.py", | |
| ) | |
| _replace( | |
| dir_root / "autonomy/tests/envs/test_math_env.py", | |
| 'report_path = Path("./math_verifier_report.txt")', | |
| 'report_path = Path(__file__).parent / "math_verifier_report.txt"', | |
| ) | |
| readme = dir_root / "autonomy/README_CLAUDE.md" | |
| replacements = { | |
| "│ ├── local_provider.py #": "│ ├── fixtures/local_provider.py #", | |
| "│ ├── test_math_verifier.py": "│ ├── envs/test_math_env.py", | |
| "│ ├── test_verifier_utils.py #": "│ ├── envs/test_verifier_utils.py #", | |
| "[test_math_verifier.py](tests/test_math_verifier.py)": ( | |
| "[test_math_env.py](tests/envs/test_math_env.py)" | |
| ), | |
| "`AutoGrader_API_Key` for live tests": "`OPENROUTER_API_KEY` for live tests", | |
| "[test_code_verifier.py](tests/test_code_verifier.py)": ( | |
| "[test_code_verifier.py](tests/utils/test_code_verifier.py)" | |
| ), | |
| "[code_verifier_test_data.json](tests/code_verifier_test_data.json)": ( | |
| "[code_verifier_test_data.json](tests/utils/code_verifier_test_data.json)" | |
| ), | |
| "[test_code_verifier_sample.py](tests/test_code_verifier_sample.py)": ( | |
| "[test_code_verifier_sample.py](tests/utils/test_code_verifier_sample.py)" | |
| ), | |
| "[test_verifier_utils.py](tests/test_verifier_utils.py)": ( | |
| "[test_verifier_utils.py](tests/envs/test_verifier_utils.py)" | |
| ), | |
| "[tests/local_provider.py](tests/local_provider.py)": ( | |
| "[tests/fixtures/local_provider.py](tests/fixtures/local_provider.py)" | |
| ), | |
| "placed in `autonomy/tests/` to prevent": ( | |
| "placed in `autonomy/tests/fixtures/` to prevent" | |
| ), | |
| } | |
| for old, new in replacements.items(): | |
| _replace(readme, old, new) | |
| git_add_and_commit("[tests, env] refactor: mirror environment tests", cwd=str(dir_root)) | |
| if __name__ == "__main__": | |
| verify_mechanical_refactor( | |
| base_commit=BASE_COMMIT, | |
| target_commit=TARGET_COMMIT, | |
| transform=transform, | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment