diff --git a/tests/functional2/lang/builtins.getEnv/test_get_env.py b/tests/functional2/lang/builtins.getEnv/test_get_env.py index 85c17fd2f..6e56c870d 100644 --- a/tests/functional2/lang/builtins.getEnv/test_get_env.py +++ b/tests/functional2/lang/builtins.getEnv/test_get_env.py @@ -1,7 +1,7 @@ from collections.abc import Callable from pathlib import Path -from functional2.lang.test_lang import test_eval as nix_eval +from functional2.lang.test_lang import test_eval_okay as nix_eval from functional2.testlib.fixtures.file_helper import with_files, File, AssetSymlink from functional2.testlib.fixtures.nix import Nix from functional2.testlib.fixtures.snapshot import Snapshot diff --git a/tests/functional2/lang/builtins.pathExists/test_path_exists.py b/tests/functional2/lang/builtins.pathExists/test_path_exists.py index deda43e01..b09aec1a5 100644 --- a/tests/functional2/lang/builtins.pathExists/test_path_exists.py +++ b/tests/functional2/lang/builtins.pathExists/test_path_exists.py @@ -1,7 +1,7 @@ from pathlib import Path from collections.abc import Callable -from functional2.lang.test_lang import test_eval as nix_eval +from functional2.lang.test_lang import test_eval_okay as nix_eval from functional2.testlib.fixtures.file_helper import ( with_files, CopyFile, diff --git a/tests/functional2/lang/builtins.readDir/test_read_dir.py b/tests/functional2/lang/builtins.readDir/test_read_dir.py index f87241fc8..e589120f6 100644 --- a/tests/functional2/lang/builtins.readDir/test_read_dir.py +++ b/tests/functional2/lang/builtins.readDir/test_read_dir.py @@ -1,7 +1,7 @@ from collections.abc import Callable from pathlib import Path -from functional2.lang.test_lang import test_eval as nix_eval +from functional2.lang.test_lang import test_eval_okay as nix_eval from functional2.testlib.fixtures.file_helper import ( with_files, CopyFile, diff --git a/tests/functional2/lang/builtins.readFileType/test_read_file_type.py b/tests/functional2/lang/builtins.readFileType/test_read_file_type.py index c4dfd8aaf..b20e220a1 100644 --- a/tests/functional2/lang/builtins.readFileType/test_read_file_type.py +++ b/tests/functional2/lang/builtins.readFileType/test_read_file_type.py @@ -1,7 +1,7 @@ from collections.abc import Callable from pathlib import Path -from functional2.lang.test_lang import test_eval as nix_eval +from functional2.lang.test_lang import test_eval_okay as nix_eval from functional2.testlib.fixtures.file_helper import ( with_files, CopyFile, diff --git a/tests/functional2/lang/search-path/test_search_path.py b/tests/functional2/lang/search-path/test_search_path.py index de16ddc4f..4d0783a71 100644 --- a/tests/functional2/lang/search-path/test_search_path.py +++ b/tests/functional2/lang/search-path/test_search_path.py @@ -1,7 +1,7 @@ from collections.abc import Callable from pathlib import Path -from functional2.lang.test_lang import test_eval as nix_eval +from functional2.lang.test_lang import test_eval_okay as nix_eval from functional2.testlib.fixtures.file_helper import AssetSymlink, CopyFile, CopyTree, with_files from functional2.testlib.fixtures.nix import Nix from functional2.testlib.fixtures.snapshot import Snapshot diff --git a/tests/functional2/lang/test_lang.py b/tests/functional2/lang/test_lang.py index d8c51a030..03caed4bc 100644 --- a/tests/functional2/lang/test_lang.py +++ b/tests/functional2/lang/test_lang.py @@ -5,7 +5,6 @@ from pathlib import Path import pytest import yaml -from _pytest.fixtures import FixtureRequest from _pytest.python import Metafunc from functional2.lang.lang_util import LangTest, fetch_all_lang_tests, LangTestRunner @@ -25,13 +24,13 @@ def pytest_generate_tests(metafunc: Metafunc): return selected_runner: LangTestRunner match func_name: - case "test_eval": + case "test_eval_okay": selected_runner = LangTestRunner.EVAL_OKAY - case "test_xfail_eval": + case "test_eval_fail": selected_runner = LangTestRunner.EVAL_FAIL - case "test_parser": + case "test_parse_okay": selected_runner = LangTestRunner.PARSE_OKAY - case "test_xfail_parser": + case "test_parse_fail": selected_runner = LangTestRunner.PARSE_FAIL case _: return @@ -42,12 +41,7 @@ def pytest_generate_tests(metafunc: Metafunc): files, flags, ids = zip(*map(LangTest.to_params, selected_tests)) # type: ignore else: files, flags, ids = [], [], [] - metafunc.parametrize(("files", "flags"), zip(files, flags), ids=ids, indirect=True) - - -@pytest.fixture -def flags(request: FixtureRequest) -> list[str]: - return request.param + metafunc.parametrize(("files", "flags"), zip(files, flags), ids=ids, indirect=["files"]) def _cleanup_output(stdout: str, stderr: str, origin: Path) -> tuple[str, str]: @@ -60,7 +54,7 @@ def _cleanup_output(stdout: str, stderr: str, origin: Path) -> tuple[str, str]: return clean_out, clean_err -def test_parser(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): +def test_parse_okay(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): nix_command = nix.nix_instantiate( ["--parse", *flags, files / "in.nix"], # TODO(Commentator2.0): Mirrors behavior of init.sh from functional @@ -89,7 +83,7 @@ def test_parser(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str assert snapshot("err.exp") == stderr -def test_xfail_parser(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): +def test_parse_fail(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): nix_command = nix.nix_instantiate(["--parse", *flags, files / "in.nix"], flake=True) result = nix_command.run().expect(1) stdout, stderr = _cleanup_output(result.stdout_s, result.stderr_s, files) @@ -98,7 +92,7 @@ def test_xfail_parser(files: Path, nix: Nix, flags: list[str], snapshot: Callabl assert snapshot("err.exp") == stderr -def test_eval(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): +def test_eval_okay(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): nix_command = nix.nix_instantiate(["--eval", "--strict", *flags, files / "in.nix"], flake=True) result = nix_command.run().ok() stdout, stderr = _cleanup_output(result.stdout_s, result.stderr_s, files) @@ -107,7 +101,7 @@ def test_eval(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], assert snapshot("err.exp") == stderr -def test_xfail_eval(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): +def test_eval_fail(files: Path, nix: Nix, flags: list[str], snapshot: Callable[[str], Snapshot]): nix_command = nix.nix_instantiate( ["--eval", "--strict", "--show-trace", *flags, files / "in.nix"], flake=True ) diff --git a/tests/functional2/lang/test_lang_infra.py b/tests/functional2/lang/test_lang_infra.py index 0265bb394..236db8025 100644 --- a/tests/functional2/lang/test_lang_infra.py +++ b/tests/functional2/lang/test_lang_infra.py @@ -23,7 +23,7 @@ from functional2.testlib.utils import get_functional2_lang_files ) def test_detects_generic_lang_test(pytest_command: Command): result = pytest_command.run().ok() - assert "lang/test_lang.py::test_eval[generic_test:eval-okay]" in result.stdout_plain + assert "lang/test_lang.py::test_eval_okay[generic_test:eval-okay]" in result.stdout_plain @pytest.mark.parametrize("pytest_command", [["-k", "toml_test", "--setup-plan"]], indirect=True) @@ -50,7 +50,7 @@ def test_detects_generic_lang_test(pytest_command: Command): ) def test_detects_toml_lang_test(pytest_command: Command): result = pytest_command.run().ok() - assert "lang/test_lang.py::test_eval[toml_test:my_name]" in result.stdout_plain + assert "lang/test_lang.py::test_eval_okay[toml_test:my_name]" in result.stdout_plain @pytest.mark.parametrize("pytest_command", [["--setup-plan"]], indirect=True) @@ -71,7 +71,7 @@ def test_detects_toml_lang_test(pytest_command: Command): ) def test_skips_py_files(files: Path, pytest_command: Command): result = pytest_command.run().ok() - assert "lang/test_lang.py::test_eval[some_py_module:eval-okay]" not in result.stdout_plain + assert "lang/test_lang.py::test_eval_okay[some_py_module:eval-okay]" not in result.stdout_plain assert ( f"[ INFO] [lang-test-collector] skipping {files.absolute()}/functional2/lang/some_py_module as it contains a py file, assuming custom tests" in result.stdout_plain @@ -223,11 +223,13 @@ def test_collection_fails_with_bad_naming(pytest_command: Command): ) def test_all_runners_work(pytest_command: Command): result = pytest_command.run().ok() - assert "lang/test_lang.py::test_eval[infra_okay_runners:eval-okay]" in result.stdout_plain - assert "lang/test_lang.py::test_parser[infra_okay_runners:parse-okay]" in result.stdout_plain - assert "lang/test_lang.py::test_xfail_eval[infra_fail_runners:eval-fail]" in result.stdout_plain + assert "lang/test_lang.py::test_eval_okay[infra_okay_runners:eval-okay]" in result.stdout_plain assert ( - "lang/test_lang.py::test_xfail_parser[infra_fail_runners:parse-fail]" in result.stdout_plain + "lang/test_lang.py::test_parse_okay[infra_okay_runners:parse-okay]" in result.stdout_plain + ) + assert "lang/test_lang.py::test_eval_fail[infra_fail_runners:eval-fail]" in result.stdout_plain + assert ( + "lang/test_lang.py::test_parse_fail[infra_fail_runners:parse-fail]" in result.stdout_plain ) @@ -628,8 +630,8 @@ def test_toml_matrix_only_list_str(pytest_command: Command): def test_toml_matrix_uses_all_files(pytest_command: Command): res = pytest_command.run().ok() out = res.stdout_plain - assert "test_eval[matrix-all:eval-okay] PASSED" in out - assert "test_eval[matrix-all:eval-okay-1] PASSED" in out + assert "test_eval_okay[matrix-all:eval-okay] PASSED" in out + assert "test_eval_okay[matrix-all:eval-okay-1] PASSED" in out @pytest.mark.parametrize("pytest_command", [[]], indirect=True) @@ -670,9 +672,9 @@ def test_toml_matrix_uses_all_files(pytest_command: Command): def test_toml_mixing_matrix_single(pytest_command: Command): res = pytest_command.run().ok() out = res.stdout_plain - assert "test_eval[mixed-matrix:eval-okay] PASSED" in out - assert "test_eval[mixed-matrix:eval-okay-1] PASSED" in out - assert "test_eval[mixed-matrix:non-matrix-1] PASSED" in out + assert "test_eval_okay[mixed-matrix:eval-okay] PASSED" in out + assert "test_eval_okay[mixed-matrix:eval-okay-1] PASSED" in out + assert "test_eval_okay[mixed-matrix:non-matrix-1] PASSED" in out @pytest.mark.parametrize("pytest_command", [[]], indirect=True) @@ -747,11 +749,11 @@ def test_toml_non_unique_name(pytest_command: Command): def test_toml_matrix_subset(pytest_command: Command): res = pytest_command.run().ok() out = res.stdout_plain - assert "test_eval[subset:matrix] PASSED" in out - assert "test_eval[subset:matrix-hello] PASSED" in out - assert "test_eval[subset:matrix-1] PASSED" not in out - assert "test_eval[subset:eval-okay-1] PASSED" in out - assert "test_eval[subset:eval-okay] PASSED" not in out + assert "test_eval_okay[subset:matrix] PASSED" in out + assert "test_eval_okay[subset:matrix-hello] PASSED" in out + assert "test_eval_okay[subset:matrix-1] PASSED" not in out + assert "test_eval_okay[subset:eval-okay-1] PASSED" in out + assert "test_eval_okay[subset:eval-okay] PASSED" not in out @pytest.mark.parametrize("pytest_command", [[]], indirect=True) @@ -816,7 +818,7 @@ def test_toml_bad_in_naming(pytest_command: Command): def test_toml_missing_in_file(pytest_command: Command): res = pytest_command.run().expect(1) out = res.stdout_plain - assert "ERROR lang/test_lang.py::test_eval[toml-missing:eval-okay] - FileNotFound" in out + assert "ERROR lang/test_lang.py::test_eval_okay[toml-missing:eval-okay] - FileNotF" in out @pytest.mark.parametrize("pytest_command", [[]], indirect=True) @@ -838,7 +840,7 @@ def test_toml_missing_in_file(pytest_command: Command): def test_generic_missing_in_file(pytest_command: Command): res = pytest_command.run().expect(1) out = res.stdout_plain - assert "ERROR lang/test_lang.py::test_eval[generic-missing:eval-okay] - FileNotFound" in out + assert "ERROR lang/test_lang.py::test_eval_okay[generic-missing:eval-okay] - FileNotF" in out @pytest.mark.parametrize("pytest_command", [["--setup-plan"]], indirect=True)