perf(plans): resolve project identity once per validation pass
This commit is contained in:
1 parent
224f4e7c1e
commit
b3883cfca1
5 files changed
+83
-30
No files matched your search
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow, compile_target_rules
|
||||
from dx_productivity.trial_task_center.store_target_plan import merge_target_inventory
|
||||
|
||||
|
||||
@pytest.mark.parametrize('operation', ['compile', 'merge'])
|
||||
def test_plan_operations_resolve_each_project_once_and_refresh_next_call(tmp_path, monkeypatch, operation):
|
||||
projects = (tmp_path / 'one.prj', tmp_path / 'two.prj')
|
||||
rows = tuple(TargetPlanRow(ComponentTarget(path, 'MAIN', '1', f'u{i}', f'R{i}', 'OLD', 'V'), True, 'NEW')
|
||||
for path in projects for i in range(20))
|
||||
original = Path.resolve
|
||||
resolved = []
|
||||
def resolve(path, *args, **kwargs):
|
||||
resolved.append(str(path))
|
||||
return original(path, *args, **kwargs)
|
||||
monkeypatch.setattr(Path, 'resolve', resolve)
|
||||
def run():
|
||||
if operation == 'compile':
|
||||
rules = compile_target_rules(rows)
|
||||
assert len(rules) == 2
|
||||
assert sum(len(rule.targets) for rule in rules) == 40
|
||||
else:
|
||||
assert merge_target_inventory(rows, tuple(row.target for row in rows)) == rows
|
||||
run()
|
||||
assert len(resolved) == 2
|
||||
resolved.clear()
|
||||
run()
|
||||
assert len(resolved) == 2, 'a later operation must resolve project identity again'
|
||||
Reference in new issue
Block a user