Skip to content

Commit

Permalink
Add getter method for built executable
Browse files Browse the repository at this point in the history
This change removes any hard coded paths to the built executable that
are outside the `CableRepository` class and replaces these with a method
that returns the path to the executable. This is done to prepare for the
changes in #183 which requires paths to vary accross different
`CableRepository` objects.

Fixes #199
  • Loading branch information
SeanBryan51 committed Nov 19, 2023
1 parent 067b1f4 commit e9110fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
8 changes: 1 addition & 7 deletions benchcab/fluxsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,7 @@ def fetch_files(self, verbose=False):
self.root_dir / internal.NAMELIST_DIR, task_dir, dirs_exist_ok=True
)

exe_src = (
self.root_dir
/ internal.SRC_DIR
/ self.repo.name
/ "offline"
/ internal.CABLE_EXE
)
exe_src = self.repo.get_exe_path()
exe_dest = task_dir / internal.CABLE_EXE

if verbose:
Expand Down
10 changes: 10 additions & 0 deletions benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ def svn_info_show_item(self, item: str) -> str:
)
return proc.stdout.strip()

def get_exe_path(self) -> Path:
"""Return the path to the built executable."""
return (
self.root_dir
/ internal.SRC_DIR
/ self.name
/ "offline"
/ internal.CABLE_EXE
)

def custom_build(self, modules: list[str], verbose=False):
"""Build CABLE using a custom build script."""
build_script_path = (
Expand Down
11 changes: 11 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ def test_undefined_repo_id(self, repo):
_ = repo.repo_id


class TestGetExePath:
"""Tests for `CableRepository.get_exe_path()`."""

def test_serial_exe_path(self, repo, mock_cwd):
"""Success case: get path to serial executable."""
assert (
repo.get_exe_path()
== mock_cwd / internal.SRC_DIR / repo.name / "offline" / internal.CABLE_EXE
)


class TestCheckout:
"""Tests for `Model.checkout()`."""

Expand Down

0 comments on commit e9110fa

Please sign in to comment.