-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(meson): fix issues with meson builds (#137)
* add test that tests meson builds for all targets * add test that tests makefile build except for targets with c++ and libmf6 * use `set_dir()` in modflow_devtools.misc * remove `working_directory()` from conftest.py * fix for meson mixed-language projects * add mf6dev, zbud6dev, and libmf6dev * remove default double precision builds for mfusg, mf2005, mflgr, and mfnwt * limit meson and makefile builds to what currently works
- Loading branch information
1 parent
3bf53a2
commit 5cd534b
Showing
18 changed files
with
270 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import os | ||
import sys | ||
import time | ||
|
||
import pytest | ||
from flaky import flaky | ||
from modflow_devtools.misc import get_ostag, set_dir | ||
|
||
import pymake | ||
|
||
RERUNS = 3 | ||
|
||
targets = pymake.usgs_program_data.get_keys(current=True) | ||
targets_make = [ | ||
t | ||
for t in targets | ||
if t not in ("libmf6", "gridgen", "mf2000", "swtv4", "mflgr") | ||
] | ||
test_ostag = get_ostag() | ||
test_fc_env = os.environ.get("FC") | ||
if "win" in test_ostag: | ||
meson_exclude = ("mt3dms", "vs2dt", "triangle", "gridgen") | ||
elif "win" not in test_ostag and test_fc_env in ("ifort",): | ||
meson_exclude = ("mf2000", "mf2005", "swtv4", "mflgr") | ||
else: | ||
meson_exclude = [] | ||
targets_meson = [t for t in targets if t not in meson_exclude] | ||
|
||
|
||
def build_with_makefile(target, path, fc): | ||
success = True | ||
with set_dir(path): | ||
if os.path.isfile("makefile"): | ||
# wait to delete on windows | ||
if sys.platform.lower() == "win32": | ||
time.sleep(6) | ||
|
||
# clean prior to make | ||
print(f"clean {target} with makefile") | ||
os.system("make clean") | ||
|
||
# build MODFLOW-NWT with makefile | ||
print(f"build {target} with makefile") | ||
return_code = os.system("make") | ||
|
||
# test if running on Windows with ifort, if True the makefile | ||
# should fail | ||
errmsg = f"{target} created by makefile does not exist." | ||
if sys.platform.lower() == "win32" and fc == "ifort": | ||
if return_code != 0: | ||
success = True | ||
else: | ||
success = False | ||
# verify that MODFLOW-NWT was made | ||
else: | ||
success = os.path.isfile(target) | ||
else: | ||
errmsg = "makefile does not exist" | ||
|
||
return success, errmsg | ||
|
||
|
||
@pytest.mark.base | ||
@flaky(max_runs=RERUNS) | ||
@pytest.mark.parametrize("target", targets) | ||
def test_build(function_tmpdir, target: str) -> None: | ||
with set_dir(function_tmpdir): | ||
assert ( | ||
pymake.build_apps( | ||
target, | ||
verbose=True, | ||
clean=False, | ||
) | ||
== 0 | ||
), f"could not compile {target}" | ||
|
||
|
||
@pytest.mark.base | ||
@flaky(max_runs=RERUNS) | ||
@pytest.mark.parametrize("target", targets_meson) | ||
def test_meson_build(function_tmpdir, target: str) -> None: | ||
with set_dir(function_tmpdir): | ||
assert ( | ||
pymake.build_apps( | ||
target, | ||
verbose=True, | ||
clean=False, | ||
meson=True, | ||
) | ||
== 0 | ||
), f"could not compile {target}" | ||
|
||
|
||
@pytest.mark.base | ||
@flaky(max_runs=RERUNS) | ||
@pytest.mark.skipif(sys.platform == "win32", reason="do not run on Windows") | ||
@pytest.mark.parametrize("target", targets_make) | ||
def test_makefile_build(function_tmpdir, target: str) -> None: | ||
pm = pymake.Pymake(verbose=True) | ||
pm.target = target | ||
pm.makefile = True | ||
pm.makefiledir = "." | ||
pm.inplace = True | ||
pm.dryrun = True | ||
pm.makeclean = False | ||
|
||
with set_dir(function_tmpdir): | ||
pm.download_target(target) | ||
assert pm.download, f"could not download {target} distribution" | ||
assert pm.build() == 0, f"could not compile {target}" | ||
|
||
success, errmsg = build_with_makefile(target, function_tmpdir, pm.fc) | ||
assert success, errmsg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.