Skip to content

Commit

Permalink
* update test_cli_cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Jun 14, 2024
1 parent b6e6380 commit 67e1d67
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
run: |
pixi run autotest-Windows
- name: Scheduled job test
if: ${{ github.event_name == 'schedule' }}
run: |
pixi run build-all
- name: Print coverage report before upload
run: |
pixi run coverage-report
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pymake-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ jobs:
run: |
pixi run autotest-Windows
- name: Scheduled job test
if: ${{ github.event_name == 'schedule' }}
run: |
pixi run build-all
- name: Print coverage report before upload
run: |
pixi run coverage-report
Expand Down
2 changes: 0 additions & 2 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import pytest

# import modflow-devtools fixtures

pytest_plugins = ["modflow_devtools.fixtures"]


Expand Down
89 changes: 54 additions & 35 deletions autotest/test_cli_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@

import pytest
from flaky import flaky
from modflow_devtools.misc import set_dir, set_env
from modflow_devtools.misc import set_dir

from pymake import linker_update_environment
import pymake

RERUNS = 3

targets = (
TARGETS = (
"triangle",
"crt",
)

meson_parm = (
MESON_PARM = (
True,
False,
)

TARGETS_ALL = pymake.usgs_program_data.get_keys(current=True)


def run_cli_cmd(cmd: list) -> None:
process = subprocess.Popen(
Expand All @@ -44,51 +46,68 @@ def run_cli_cmd(cmd: list) -> None:
@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="make_program")
@pytest.mark.base
@pytest.mark.parametrize("target", targets)
@pytest.mark.parametrize("target", TARGETS)
def test_make_program(function_tmpdir, target: str) -> None:
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="make_program")
@pytest.mark.dependency(name="make_program_mf2005")
@pytest.mark.base
def test_make_program_double(function_tmpdir) -> None:
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)


@pytest.mark.dependency(name="make_program_all")
@pytest.mark.schedule
def test_make_program_all(module_tmpdir) -> None:
cmd = [
"make-program",
":",
"--appdir",
str(module_tmpdir / "all"),
"--verbose",
"--dryrun",
]
run_cli_cmd(cmd)
def test_make_program_all(function_tmpdir) -> None:
with set_dir(function_tmpdir):
cmd = [
"make-program",
":",
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@pytest.mark.dependency(name="make_program_all_parametrize")
@pytest.mark.schedule
@pytest.mark.parametrize("target", TARGETS_ALL)
def test_make_program_all_parametrize(function_tmpdir, target: str) -> None:
with set_dir(function_tmpdir):
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="mfpymake")
@pytest.mark.base
@pytest.mark.parametrize("meson", meson_parm)
@pytest.mark.parametrize("meson", MESON_PARM)
def test_mfpymake(function_tmpdir, meson: bool) -> None:
with set_dir(function_tmpdir):
src = (
Expand Down Expand Up @@ -116,7 +135,7 @@ def test_mfpymake(function_tmpdir, meson: bool) -> None:
fc = os.environ.get("FC")
cmd.append(fc)

linker_update_environment(fc=fc)
pymake.linker_update_environment(fc=fc)

if meson:
cmd.append("--meson")
Expand Down
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ download-examples = {cmd = "python ci_setup.py", cwd = "autotest"}
autotest = { cmd = "pytest -v -n auto --dist=loadfile -m='base or regression' --durations 0 --cov=pymake --cov-report=xml --keep-failed .failed", cwd = "autotest" }
autotest-base = { cmd = "pytest -v -n auto --dist=loadfile -m='base' --durations 0 --cov=pymake --cov-report=xml --keep-failed .failed", cwd = "autotest" }
autotest-Windows = { cmd = "pytest -v -m='base' --durations 0 --cov=pymake --cov-report=xml --basetemp=$RUNNER_TEMP/pytest_temp --keep-failed .failed", cwd = "autotest" }
build-all = { cmd = "pytest -v -m='schedule' -n auto --keep-failed .failed test_cli_cmds.py", cwd = "autotest" }

# coverage report
coverage-report = { cmd = "coverage report", cwd = "autotest"}

0 comments on commit 67e1d67

Please sign in to comment.