From 67e1d67e7d823ce1692db0a87f82c82bde04f729 Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Fri, 14 Jun 2024 10:46:00 -0500 Subject: [PATCH] * update test_cli_cmds --- .github/workflows/main.yml | 5 ++ .github/workflows/pymake-gcc.yml | 5 ++ autotest/conftest.py | 2 - autotest/test_cli_cmds.py | 89 +++++++++++++++++++------------- pixi.toml | 1 + 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12a80f4..ba6514e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/.github/workflows/pymake-gcc.yml b/.github/workflows/pymake-gcc.yml index 206607f..e86bf6c 100644 --- a/.github/workflows/pymake-gcc.yml +++ b/.github/workflows/pymake-gcc.yml @@ -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 diff --git a/autotest/conftest.py b/autotest/conftest.py index 1a11328..92a48fc 100644 --- a/autotest/conftest.py +++ b/autotest/conftest.py @@ -6,8 +6,6 @@ import pytest -# import modflow-devtools fixtures - pytest_plugins = ["modflow_devtools.fixtures"] diff --git a/autotest/test_cli_cmds.py b/autotest/test_cli_cmds.py index f31e0a3..4d87177 100644 --- a/autotest/test_cli_cmds.py +++ b/autotest/test_cli_cmds.py @@ -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( @@ -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 = ( @@ -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") diff --git a/pixi.toml b/pixi.toml index 63f34b4..e505be6 100644 --- a/pixi.toml +++ b/pixi.toml @@ -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"}