Skip to content

Commit ee5a61d

Browse files
authored
fix: empty paths result in root-relative error (#154)
1 parent b163aba commit ee5a61d

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

crates/hm-dsl-engine/harmont-py/harmont/_rust.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,9 @@ def _make_rust_project(
743743
components=components,
744744
base=base,
745745
)
746-
746+
# set empty file path to "." to prevent root-relative from happening
747+
if not path:
748+
path = "."
747749
lock_path = f"{path}/Cargo.lock" if path != "." else "Cargo.lock"
748750
toml_glob = f"{path}/**/Cargo.toml" if path != "." else "**/Cargo.toml"
749751
rs_glob = f"{path}/**/*.rs" if path != "." else "**/*.rs"

crates/hm-dsl-engine/harmont-py/tests/test_rust.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
from __future__ import annotations
44

55
import pytest
6+
import tempfile
67

78
import harmont as hm
89
from harmont.cache import CacheOnChange
10+
from harmont.keygen import resolve_pipeline_keys
11+
from pathlib import Path
12+
913

1014

1115
def _cmds(p: dict) -> list[str]:
@@ -328,6 +332,36 @@ def test_project_has_all_methods(self):
328332
assert proj.clippy().cmd is not None
329333
assert proj.fmt().cmd is not None
330334

335+
336+
def test_empty_path_throws_error_is_caught(self):
337+
proj = hm.rust.project(path="")
338+
graph = {
339+
"nodes": [
340+
{
341+
"step": {
342+
"key": "a",
343+
"cmd": "cargo build",
344+
"cache": {"policy": "on_change", "paths": [p for p in list(proj.warmup.cache.paths)]},
345+
},
346+
"env": {},
347+
},
348+
],
349+
"node_holes": [],
350+
"edge_property": "directed",
351+
"edges": [],
352+
}
353+
354+
with tempfile.TemporaryDirectory() as d:
355+
res = resolve_pipeline_keys(
356+
graph,
357+
pipeline_org="default",
358+
pipeline_slug="default",
359+
now=0,
360+
base_path=Path(d),
361+
env={}
362+
)
363+
assert res['nodes'][0]['step']['cache']['key'] is not None
364+
331365
def test_warmup_implicit_cache_on_change(self):
332366
proj = hm.rust.project(path="cli")
333367
assert proj.warmup.cache == CacheOnChange(

0 commit comments

Comments
 (0)