Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make sure output directories are generated if not pre-existing #50

Merged
merged 1 commit into from
Feb 22, 2023
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
12 changes: 0 additions & 12 deletions bl45p-mo-ioc-03.boot

This file was deleted.

10 changes: 0 additions & 10 deletions bl45p-mo-ioc-04.boot

This file was deleted.

11 changes: 0 additions & 11 deletions ioc.boot

This file was deleted.

2 changes: 2 additions & 0 deletions src/ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def build_startup(
ioc_instance = ioc_deserialize(instance, definitions)
script_txt = create_boot_script(ioc_instance)

out.parent.mkdir(parents=True, exist_ok=True)

with out.open("w") as stream:
stream.write(script_txt)

Expand Down
27 changes: 27 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,33 @@ def test_container_schema(tmp_path: Path, samples: Path):
assert expected == actual


def test_build_startup_output_path(tmp_path: Path, samples: Path):
"""
build an ioc startup script and ensure output directory gets generated
if it doesn't pre-exist
"""
clear_entity_classes()
entity_file = samples / "yaml" / "bl45p-mo-ioc-02.ibek.entities.yaml"
definition_file = samples / "yaml" / "pmac.ibek.defs.yaml"
out_file = tmp_path / "new_dir" / "ioc.boot"
out_db = tmp_path / "new_dir" / "make_db.sh"

run_cli(
"build-startup",
entity_file,
definition_file,
"--out",
out_file,
"--db-out",
out_db,
)

example_boot = (samples / "boot_scripts" / "ioc.boot").read_text()
actual_boot = out_file.read_text()

assert example_boot == actual_boot


def test_build_startup_single(tmp_path: Path, samples: Path):
"""
build an ioc startup script from an IOC instance entity file
Expand Down