diff --git a/configure/E3/CONFIG_CELL b/configure/E3/CONFIG_CELL index 742bd0762bc7ec14c720d1050c0a2a4e4d34faf6..4dafb395cb505e6ece363821c17f714cfaf02548 100644 --- a/configure/E3/CONFIG_CELL +++ b/configure/E3/CONFIG_CELL @@ -2,7 +2,7 @@ # TOP is e3-MODULENAME ifneq (,$(findstring cell,$(MAKECMDGOALS))) ## Default is e3-MODULENAME/cellMods -E3_CELL_PATH?=$(TOP)/cellMods +E3_CELL_PATH=$(TOP)/cellMods ## ## Allow local file in $(TOP)/configure ## local file in $(TOP)/../ diff --git a/tests/conftest.py b/tests/conftest.py index 3e98fcef97a31ab7141164c58edef90440e18949..73ecb72baf2ecc565cba279044139e069f648ed5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,6 +19,9 @@ class Wrapper: self.module_dir = self.path / module_path self.module_dir.mkdir(parents=True) + self.config_dir = self.path / "configure" + self.config_dir.mkdir() + self.makefile = self.path / f"{name}.Makefile" makefile_contents = f""" @@ -50,6 +53,11 @@ include $(E3_REQUIRE_TOOLS)/driver.makefile def add_file(self, name): (self.module_dir / name).touch() + def write_local_data(self, config_file, **kwargs): + with open(self.config_dir / f"{config_file}.local", "w") as f: + for var, value in kwargs.items(): + f.write(f"{var} = {value}\n") + def add_var_to_makefile(self, makefile_var, value, modifier="+"): with open(self.makefile, "a") as f: f.write(f"{makefile_var} {modifier}= {value}\n") diff --git a/tests/test_build.py b/tests/test_build.py index a7932e64c1af5748495345e58586b68fc46c3d2b..3427b3c54cbf3488dcd8ab73e4e37de43b5081e7 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -45,23 +45,23 @@ def test_patch(wrapper): rc, outs, _ = run_make( wrapper, "init", - E3_MODULE_VERSION=MODULE_VERSION, + module_version=MODULE_VERSION, ) assert rc == 0 assert "You are in the local source mode" in outs - rc, _, _ = run_make(wrapper, "patch", E3_MODULE_VERSION=MODULE_VERSION) + rc, _, _ = run_make(wrapper, "patch", module_version=MODULE_VERSION) 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, _, _ = run_make(wrapper, "build", E3_MODULE_VERSION=MODULE_VERSION) + rc, _, _ = run_make(wrapper, "build", module_version=MODULE_VERSION) assert rc == 0 assert any((wrapper.module_dir).glob("O.*")) - rc, _, _ = run_make(wrapper, "cellinstall", E3_MODULE_VERSION=MODULE_VERSION) + rc, _, _ = run_make(wrapper, "cellinstall", module_version=MODULE_VERSION) assert rc == 0 assert any((wrapper.path / "cellMods").glob("**/*.db")) @@ -134,12 +134,12 @@ def test_updated_dependencies(wrappers): rc, *_ = run_make( wrapper_dep, "cellinstall", - E3_CELL_PATH=cell_path, - E3_MODULE_VERSION=old_version, + module_version=old_version, + cell_path=cell_path, ) assert rc == 0 - rc, *_ = run_make(wrapper_main, "cellinstall", E3_MODULE_VERSION=old_version) + rc, *_ = run_make(wrapper_main, "cellinstall", module_version=old_version) assert rc == 0 new_version = "1.0.0+0" @@ -147,8 +147,8 @@ def test_updated_dependencies(wrappers): rc, *_ = run_make( wrapper_dep, "cellinstall", - E3_CELL_PATH=cell_path, - E3_MODULE_VERSION=new_version, + module_version=new_version, + cell_path=cell_path, ) assert rc == 0 @@ -156,7 +156,7 @@ def test_updated_dependencies(wrappers): f"{wrapper_dep.name}_VERSION", new_version, modifier="" ) - rc, *_ = run_make(wrapper_main, "cellinstall", E3_MODULE_VERSION=new_version) + rc, *_ = run_make(wrapper_main, "cellinstall", module_version=new_version) assert rc == 0 rc, o, _ = run_ioc_get_output( diff --git a/tests/test_e3.py b/tests/test_e3.py index a02e16725b9ae93a4bd23a9c93176b91ebe53233..8de0548983acf3da72f5f56ae8a640854e40631e 100644 --- a/tests/test_e3.py +++ b/tests/test_e3.py @@ -39,6 +39,6 @@ def test_incorrect_module_name(wrappers): module_name = "ADCore" wrapper = wrappers.get(name=module_name) - rc, _, errs = run_make(wrapper, "build", E3_MODULE_NAME=module_name) + rc, _, errs = run_make(wrapper, "build", module_name=module_name) assert rc == 2 assert f"E3_MODULE_NAME '{module_name}' is not valid" in errs diff --git a/tests/test_versions.py b/tests/test_versions.py index f8d1b7baf75b9c806ac209ef9e2bd4b7b017a084..4866df7237faa42ccfed67d0623c9e2d5cf46815 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -40,7 +40,7 @@ def test_version(wrapper, requested, expected, installed): wrapper, "clean", "cellinstall", - E3_MODULE_VERSION=version, + module_version=version, ) assert returncode == 0 diff --git a/tests/utils.py b/tests/utils.py index de790a3dead13a1ace2b3bd72fdc4c96d6461b1a..17e068039166fd5902cdfe3439384cb29791f8c0 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,6 +3,7 @@ import subprocess import time from pathlib import Path +from .conftest import Wrapper from run_iocsh import IOC EPICS_BASE = os.environ.get("EPICS_BASE") @@ -28,13 +29,17 @@ def set_env_vars(env: dict) -> dict: return env -def run_make(wrapper, *args, **kwargs): +def run_make(wrapper: Wrapper, *args, module_name: str = "", module_version: str = "", cell_path: str=""): """ Attempt to run `make <args>` in the specified path with <kwargs> as environment variables """ test_env = set_env_vars(os.environ.copy()) - for kw in kwargs: - test_env[kw] = kwargs[kw] + if module_name: + test_env["E3_MODULE_NAME"] = module_name + if module_version: + test_env["E3_MODULE_VERSION"] = module_version + if cell_path: + wrapper.write_local_data("CONFIG_CELL", E3_CELL_PATH=cell_path) make_cmd = ["make", "-C", wrapper.path] + list(args) p = subprocess.Popen( make_cmd,