MCPcopy
hub / github.com/treeverse/dvc / test_foreach_with_interpolated_wdir

Function test_foreach_with_interpolated_wdir

tests/func/parsing/test_foreach.py:253–271  ·  view source on GitHub ↗
(tmp_dir, dvc)

Source from the content-addressed store, hash-verified

251
252
253def test_foreach_with_interpolated_wdir(tmp_dir, dvc):
254 resolver = DataResolver(dvc, (tmp_dir / "data").fs_path, {})
255 foreach_data = ["foo", "bar"]
256 data = {
257 "foreach": foreach_data,
258 "do": {"wdir": "${item}", "cmd": "echo hello"},
259 }
260 definition = ForeachDefinition(resolver, resolver.context, "build", data)
261
262 assert definition.resolve_all() == {
263 # note that the resolver generates `wdir` relative to file's wdir
264 # so, this is just `foo`, not `data/foo`.
265 # figuring out `wdir` is the responsibility of the `load_stage`/`Stage`
266 "build@foo": {"wdir": "foo", "cmd": "echo hello"},
267 "build@bar": {"wdir": "bar", "cmd": "echo hello"},
268 }
269
270 assert not resolver.context
271 assert not any(item for item in resolver.tracked_vars.values())
272
273
274def test_foreach_with_local_vars(tmp_dir, dvc):

Callers

nothing calls this directly

Calls 3

resolve_allMethod · 0.95
DataResolverClass · 0.90
ForeachDefinitionClass · 0.90

Tested by

no test coverage detected