Skip to content

Commit b1a7ffb

Browse files
authored
Merge pull request #206 from CABLE-LSM/199-add-getter-for-exe-path
Add getter method for built executable
2 parents 067b1f4 + e9110fa commit b1a7ffb

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

benchcab/fluxsite.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,7 @@ def fetch_files(self, verbose=False):
264264
self.root_dir / internal.NAMELIST_DIR, task_dir, dirs_exist_ok=True
265265
)
266266

267-
exe_src = (
268-
self.root_dir
269-
/ internal.SRC_DIR
270-
/ self.repo.name
271-
/ "offline"
272-
/ internal.CABLE_EXE
273-
)
267+
exe_src = self.repo.get_exe_path()
274268
exe_dest = task_dir / internal.CABLE_EXE
275269

276270
if verbose:

benchcab/model.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def svn_info_show_item(self, item: str) -> str:
7676
)
7777
return proc.stdout.strip()
7878

79+
def get_exe_path(self) -> Path:
80+
"""Return the path to the built executable."""
81+
return (
82+
self.root_dir
83+
/ internal.SRC_DIR
84+
/ self.name
85+
/ "offline"
86+
/ internal.CABLE_EXE
87+
)
88+
7989
def custom_build(self, modules: list[str], verbose=False):
8090
"""Build CABLE using a custom build script."""
8191
build_script_path = (

tests/test_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ def test_undefined_repo_id(self, repo):
4646
_ = repo.repo_id
4747

4848

49+
class TestGetExePath:
50+
"""Tests for `CableRepository.get_exe_path()`."""
51+
52+
def test_serial_exe_path(self, repo, mock_cwd):
53+
"""Success case: get path to serial executable."""
54+
assert (
55+
repo.get_exe_path()
56+
== mock_cwd / internal.SRC_DIR / repo.name / "offline" / internal.CABLE_EXE
57+
)
58+
59+
4960
class TestCheckout:
5061
"""Tests for `Model.checkout()`."""
5162

0 commit comments

Comments
 (0)