Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mechababs/campaign_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ def stage_config(dest_dir, arg, what):
with urllib.request.urlopen(arg) as response: # http/https only, checked above
dest.write_bytes(response.read())
return name
source = Path(arg)
# The shell expands `~` only at the start of a word, so a `~` inside a
# comma-joined `--apps a.yaml,~/b.yaml` arrives literal.
source = Path(arg).expanduser()
if not source.is_file():
sys.exit(
f"{what} config not found: {arg}\n"
Expand Down
12 changes: 12 additions & 0 deletions tests/test_campaign_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@ def test_pyproject_pins_mechababs_and_babs_by_ref(study, configs, stub_env):
assert "[build-system]" not in pyproject


def test_a_config_path_with_a_literal_tilde_is_expanded(tmp_path, monkeypatch):
# `--apps a.yaml,~/b.yaml`: the shell expands only a word-initial `~`, so the
# second path arrives with the `~` still in it
monkeypatch.setenv("HOME", str(tmp_path))
(tmp_path / "MRIQC-24.0.2.yaml").write_text("{}\n")
dest = tmp_path / "staged"
assert campaign_init.stage_config(dest, "~/MRIQC-24.0.2.yaml", "app") == (
"MRIQC-24.0.2.yaml"
)
assert (dest / "MRIQC-24.0.2.yaml").is_file()


def test_a_local_checkout_pin_becomes_a_file_url(tmp_path):
# dev mode: run a whole campaign against a branch that exists only on disk
checkout = tmp_path / "babs-checkout"
Expand Down
Loading