diff --git a/tests/conftest.py b/tests/conftest.py index 12ada8cb85b569f864c05d583a3621510969990d..4ff2cb9a5e54a8a6cc5894c115f41864a8fa7b9d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,6 +29,8 @@ class Wrapper: self.path = root_path / f"e3-{name}" self.name = name + self.version = "0.0.0+0" + module_path = ( name if "E3_MODULE_SRC_PATH" not in kwargs else kwargs["E3_MODULE_SRC_PATH"] ) @@ -46,7 +48,7 @@ class Wrapper: TOP:=$(CURDIR) E3_MODULE_NAME:={name} -E3_MODULE_VERSION?=0.0.0+0 +E3_MODULE_VERSION:={self.version} E3_MODULE_SRC_PATH:={module_path} E3_MODULE_MAKEFILE:={name}.Makefile @@ -117,17 +119,16 @@ EXCLUDE_ARCHS+=debug if target == "uninstall": target = "celluninstall" - env = os.environ.copy() + args = list(args) if module_version: - env["E3_MODULE_VERSION"] = module_version + args.append(f"E3_MODULE_VERSION={module_version}") if cell_path: self.write_dot_local_data("CONFIG_CELL", {"E3_CELL_PATH": cell_path}) - make_cmd = ["make", "-C", self.path, target] + list(args) + make_cmd = ["make", "-C", self.path, target] + args p = subprocess.Popen( make_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env, encoding="utf-8", ) outs, errs = p.communicate() diff --git a/tests/test_build.py b/tests/test_build.py index 2c036771da531e9b3be91f2ef9c6def6df783e6b..8f8f774ff54933965aaca4f123a0156cd5452416 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -7,9 +7,6 @@ import pytest from .conftest import Wrapper from .utils import run_ioc_get_output -MODULE_VERSION = "0.0.0+0" -MODULE_VERSION_NO_BUILD = "0.0.0" - RE_MISSING_FILE = "No rule to make target [`']{filename}'" RE_MISSING_VERSION = "Module '{module}' version '{version}' does not exist." RE_MODULE_VERSION_EXISTS = "Error .*{module}/{version}.* already exists" @@ -43,29 +40,26 @@ def test_patch(wrapper: Wrapper): patch_dir = wrapper.path / "patch" create_patch_file(patch_dir / "apply.p0.patch", "OK") - create_patch_file(patch_dir / MODULE_VERSION / "do-not-apply.p0.patch", "Bad") + create_patch_file(patch_dir / wrapper.version / "do-not-apply.p0.patch", "Bad") - rc, _, _ = wrapper.run_make("patch", module_version=MODULE_VERSION) + rc, _, _ = wrapper.run_make("patch") assert rc == 0 with open(db_path, "r") as f: db_contents = f.read() assert 'field(DESC, "OK")' in db_contents assert "Bad" not in db_contents - rc, _, _ = wrapper.run_make("build", module_version=MODULE_VERSION) + rc, _, _ = wrapper.run_make("build") assert rc == 0 assert any((wrapper.module_dir).glob("O.*")) - rc, _, _ = wrapper.run_make("cellinstall", module_version=MODULE_VERSION) + rc, _, _ = wrapper.run_make("cellinstall") assert rc == 0 assert any((wrapper.path / "cellMods").glob("**/*.db")) def test_local_module(wrapper: Wrapper): - rc, outs, _ = wrapper.run_make( - "init", - module_version=MODULE_VERSION, - ) + rc, outs, _ = wrapper.run_make("init") assert rc == 0 assert "You are in the local source mode" in outs @@ -596,14 +590,14 @@ def test_build_fails_if_nth_architecture_fails(wrapper: Wrapper, archs, failing_ def test_double_install_fails(wrapper: Wrapper): RE_ERR_MOD_VER_EXISTS = ".*{module}/{version}.* already exists" - rc, *_ = wrapper.run_make("install", module_version=MODULE_VERSION) + rc, *_ = wrapper.run_make("install") assert rc == 0 - rc, _, errs = wrapper.run_make("install", module_version=MODULE_VERSION) + rc, _, errs = wrapper.run_make("install") assert rc == 2 assert re.search( RE_ERR_MOD_VER_EXISTS.format( - module=re.escape(wrapper.name), version=re.escape(MODULE_VERSION) + module=re.escape(wrapper.name), version=re.escape(wrapper.version) ), errs, ) diff --git a/tests/test_versions.py b/tests/test_versions.py index 523d4594d4d13781208e118ba033b6683b769238..dcec1f4e7f2b638b0767f8dfd6639033dcaeb819 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -15,24 +15,24 @@ RE_MODULE_NOT_LOADED = "Module {module} (not available|version {required} not av # If nothing is installed, nothing should be loaded ("", "", []), # Test versions can be loaded - ("test", "test", ["test", "0.0.1"]), + ("test", "test", ["test", "0.0.1+0"]), # Numeric versions should be prioritized over test versions - ("", "0.0.1+0", ["test", "0.0.1"]), - ("", "0.0.1+0", ["0.0.1", "test"]), + ("", "0.0.1+0", ["test", "0.0.1+0"]), + ("", "0.0.1+0", ["0.0.1+0", "test"]), # Highest build number should be loaded if version is unspecified - ("", "0.0.1+7", ["0.0.1", "0.0.1+7", "0.0.1+3"]), + ("", "0.0.1+7", ["0.0.1+0", "0.0.1+7", "0.0.1+3"]), # Only load the given build number if it is specified ("0.0.1+0", "", ["0.0.1+1"]), # If no build number is specified, load the highest build number - ("0.0.1", "0.0.1+4", ["0.1.0", "0.0.1+4", "0.0.1"]), + ("0.0.1", "0.0.1+4", ["0.1.0+0", "0.0.1+4", "0.0.1+0"]), # Build number 0 means load that version exactly ("0.0.1+0", "0.0.1+0", ["0.0.1+0"]), - ("0.0.1+0", "0.0.1+0", ["0.0.1", "0.0.1+1", "1.0.0"]), + ("0.0.1+0", "0.0.1+0", ["0.0.1+0", "0.0.1+1", "1.0.0+0"]), # 1-test counts as a test version, as does 1.0 - ("", "0.0.1+0", ["0.0.1", "1-test"]), - ("", "0.0.1+0", ["0.0.1", "1.0"]), + ("", "0.0.1+0", ["0.0.1+0", "1-test"]), + ("", "0.0.1+0", ["0.0.1+0", "1.0"]), # Numeric version should be prioritised over "higher" test version - ("", "0.1.0+0", ["0.1.0", "1.0.0-rc1"]), + ("", "0.1.0+0", ["0.1.0+0", "1.0.0-rc1"]), ], ) def test_version(wrapper: Wrapper, requested, expected, installed):