Run isolated export tasks concurrently and overlap cleanup

This commit is contained in:
阿白叔 committed 2026-11-09 14:35:48 +08:00
1 parent 5b974c9b45
commit 8029d146cb
8 files changed
+341 -41

No files matched your search

+18
View File
@@ -131,3 +131,21 @@ def test_preflight_exception_is_a_warning_not_a_batch_blocker(tmp_path, monkeypa
monkeypatch.setattr(cli, "_save_settings", lambda value: None)
assert cli.main(["--input", str(tmp_path), "--output", str(tmp_path / "out"), "--yes"]) == 0
assert list((tmp_path / "out").glob("批次_*/batch.json"))
def test_batch_passes_worker_limit_and_records_execution_mode(tmp_path):
from mentorexport.cli import run_batch
limits = []
def exporter(project, installation, folder, shared, **options):
limits.append(options["jobs"])
return {"status": "success", "items": []}
batch, code = run_batch([{"name": "工程", "path": str(tmp_path / "a.prj")}], [], {},
tmp_path / "out", tmp_path, exporter=exporter, jobs=2)
record = json.loads((batch / "batch.json").read_text(encoding="utf-8"))
assert code == 0 and limits == [2] and record["execution"]["jobs"] == 2
def test_invalid_worker_limit_does_not_start_export(tmp_path):
from mentorexport.cli import main
for jobs in ("0", "9"):
assert main(["--input", str(tmp_path), "--jobs", jobs, "--yes"]) == 2