Download tasks/format-code-task-000023/tests/test.patch from FineEnvs/MiMo-V2.6-RL-harbor-code: direct link, hf CLI and curl.
- Browser
- Download file 5.53 kB
-
https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000023/tests/test.patch
- Command line
-
hf download hf://datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/tasks/format-code-task-000023/tests/test.patch
-
curl -L -o test.patch https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000023/tests/test.patch
5.53 kB
| diff --git a/tests/functional/project/test_project_manager_cache_contract.py b/tests/functional/project/test_project_manager_cache_contract.py | |
| new file mode 100644 | |
| index 000000000..e9a040eb0 | |
| --- /dev/null | |
| +++ b/tests/functional/project/test_project_manager_cache_contract.py | |
| +from types import SimpleNamespace | |
| + | |
| +from ape.managers.project import ProjectManager | |
| +from ape.types import ContractType | |
| + | |
| + | |
| +class RecordingCompiler: | |
| + def __init__(self): | |
| + self.calls = [] | |
| + | |
| + def compile(self, paths): | |
| + paths = list(paths) | |
| + self.calls.append(tuple(str(path) for path in paths)) | |
| + return [ | |
| + ContractType( | |
| + contractName=f"{path.stem}:{path.read_text()}", | |
| + sourceId=str(path), | |
| + abi=[], | |
| + ) | |
| + for path in paths | |
| + ] | |
| + | |
| + | |
| +class CompilerManagerStub: | |
| + def __init__(self, compiler): | |
| + self.compiler = compiler | |
| + self.registered_compilers = {".foo": compiler} | |
| + | |
| + def compile(self, paths): | |
| + return { | |
| + contract.contractName: contract | |
| + for contract in self.compiler.compile(paths) | |
| + } | |
| + | |
| + | |
| +def make_project(tmp_path, compiler=None): | |
| + compiler = compiler or RecordingCompiler() | |
| + config = SimpleNamespace(PROJECT_FOLDER=tmp_path, name="", dependencies=[]) | |
| + return ProjectManager(tmp_path, config, CompilerManagerStub(compiler)), compiler | |
| + | |
| + | |
| +def test_missing_contract_directory_has_no_unknown_extensions(tmp_path): | |
| + project, _ = make_project(tmp_path) | |
| + | |
| + assert project.sources_missing is True | |
| + assert project.extensions_with_missing_compilers == [] | |
| + | |
| + | |
| +def test_empty_contract_directory_is_reported_as_missing(tmp_path): | |
| + project, _ = make_project(tmp_path) | |
| + (tmp_path / "contracts").mkdir() | |
| + assert project.sources_missing is True | |
| + assert project.extensions_with_missing_compilers == [] | |
| + | |
| + | |
| +def make_nested_sources(tmp_path): | |
| + project, _ = make_project(tmp_path) | |
| + contracts = tmp_path / "contracts" | |
| + (contracts / "nested").mkdir(parents=True) | |
| + for relative in ( | |
| + "z.foo", | |
| + "a.bar", | |
| + "q.zeta", | |
| + "nested/m.foo", | |
| + "nested/b.bar", | |
| + "nested/a.alpha", | |
| + ): | |
| + (contracts / relative).write_text(relative) | |
| + return project, contracts | |
| + | |
| + | |
| +def test_sources_are_recursive_and_sorted(tmp_path): | |
| + project, contracts = make_nested_sources(tmp_path) | |
| + assert [path.relative_to(contracts).as_posix() for path in project.sources] == [ | |
| + "nested/m.foo", | |
| + "z.foo", | |
| + ] | |
| + | |
| + | |
| +def test_unknown_extensions_are_recursive_and_sorted(tmp_path): | |
| + project, _ = make_nested_sources(tmp_path) | |
| + assert project.extensions_with_missing_compilers == [".alpha", ".bar", ".zeta"] | |
| + | |
| + | |
| +def test_corrupt_manifest_cache_is_ignored_and_rebuilt(tmp_path): | |
| + project, compiler = make_project(tmp_path) | |
| + contracts = tmp_path / "contracts" | |
| + contracts.mkdir() | |
| + source = contracts / "one.foo" | |
| + source.write_text("v1") | |
| + cache = tmp_path / ".build" / "__local__.json" | |
| + cache.parent.mkdir() | |
| + cache.write_text("not-json") | |
| + | |
| + loaded = project.load_contracts() | |
| + | |
| + assert set(loaded) == {"one:v1"} | |
| + assert compiler.calls == [(str(source),)] | |
| + | |
| + | |
| +def setup_cached_sources(tmp_path): | |
| + project, compiler = make_project(tmp_path) | |
| + contracts = tmp_path / "contracts" | |
| + contracts.mkdir() | |
| + first = contracts / "first.foo" | |
| + second = contracts / "second.foo" | |
| + first.write_text("v1") | |
| + second.write_text("v1") | |
| + | |
| + initial = project.load_contracts() | |
| + assert set(initial) == {"first:v1", "second:v1"} | |
| + assert compiler.calls[-1] == (str(first), str(second)) | |
| + return project, compiler, contracts, first, second | |
| + | |
| + | |
| +def test_incremental_cache_compiles_only_changed_and_new_sources(tmp_path): | |
| + project, compiler, contracts, first, second = setup_cached_sources(tmp_path) | |
| + first.write_text("v2") | |
| + third = contracts / "third.foo" | |
| + third.write_text("v1") | |
| + updated = project.load_contracts() | |
| + assert compiler.calls[-1] == (str(first), str(third)) | |
| + assert "second:v1" in updated | |
| + assert "third:v1" in updated | |
| + | |
| + | |
| +def test_changed_source_replaces_its_stale_contract_types(tmp_path): | |
| + project, _, _, first, _ = setup_cached_sources(tmp_path) | |
| + first.write_text("v2") | |
| + updated = project.load_contracts() | |
| + assert "first:v1" not in updated | |
| + assert updated["first:v2"].sourceId == str(first) | |
| + | |
| + | |
| +def test_deleted_source_drops_its_cached_contract_types(tmp_path): | |
| + project, _, _, _, second = setup_cached_sources(tmp_path) | |
| + second.unlink() | |
| + project.load_contracts() | |
| + | |
| + reloaded_project, _ = make_project(tmp_path) | |
| + after_delete = reloaded_project.load_contracts() | |
| + assert set(after_delete) == {"first:v1"} | |
| + | |
| + | |
| +def test_force_rebuild_recompiles_all_current_sources(tmp_path): | |
| + project, compiler = make_project(tmp_path) | |
| + contracts = tmp_path / "contracts" | |
| + contracts.mkdir() | |
| + first = contracts / "first.foo" | |
| + second = contracts / "second.foo" | |
| + first.write_text("v1") | |
| + second.write_text("v1") | |
| + | |
| + project.load_contracts() | |
| + project.load_contracts(use_cache=False) | |
| + | |
| + assert compiler.calls[-1] == (str(first), str(second)) | |
| diff --git a/mimo_test_command.sh b/mimo_test_command.sh | |
| new file mode 100755 | |
| --- /dev/null | |
| +++ b/mimo_test_command.sh | |
| +#!/bin/bash | |
| +set -euo pipefail | |
| + | |
| + | |
| +pytest -q tests/functional/project/test_project_manager_cache_contract.py | |
| + | |