elegant-art-7479
05/08/2025, 9:17 PMfiles or docker_image, but because no imports are allowed in the macro files, patching doesn't really work. I'd expect there are some utils that let us verify if given target functions were calledfast-nail-55400
05/09/2025, 2:15 AMfast-nail-55400
05/09/2025, 2:16 AMRuleRunner mechanisms and just check the fields on those targets.fast-nail-55400
05/09/2025, 2:19 AMRuleRunner and then query the engine for what it created.)elegant-art-7479
05/09/2025, 1:56 PMfast-nail-55400
05/09/2025, 2:16 PMelegant-art-7479
05/09/2025, 2:17 PMbuild_file_prelude_globs = [
'pants_plugins/macros.py',
]
in pants.tomlfast-nail-55400
05/09/2025, 2:19 PMeval the string with appropriate test fixtures injected to stand in for the BUILD file symbols the macros uses. Check results.elegant-art-7479
05/09/2025, 2:21 PMeval - I didn't think of it, and tried to actually import the macro from a test. Ok, I'll try it, thanks! I'm thinking about a feature request to make it less hacky, perhaps encapsulating what you suggest into some test utilscurved-manchester-66006
05/09/2025, 2:22 PMfast-nail-55400
05/09/2025, 2:22 PMwith open("pants_plugins/macros.py") as f:
macro = f.read()
generated_targets = []
def my_target_standin(*args, **kwargs):
nonlocal generated_targets
generated_targets.append((args, kwargs))
eval(macro, globals={"env": some_env_standin, "my_target": my_target_standin})
# check `generated targets`fast-nail-55400
05/09/2025, 2:23 PM