Skip to content
Snippets Groups Projects
Commit 73bbc073 authored by Simon Rose's avatar Simon Rose
Browse files

Removed E3_CELL_PATH environment override

This was needed since we had to have a way for the test suites to override this value. However,
this can also be acheived by writing to configure/CONFIG_CELL.local. This was added in a
refactoring of run_make to make more clear what variables can be passed there.
parent 04e21083
No related branches found
Tags 3.4.4
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# TOP is e3-MODULENAME # TOP is e3-MODULENAME
ifneq (,$(findstring cell,$(MAKECMDGOALS))) ifneq (,$(findstring cell,$(MAKECMDGOALS)))
## Default is e3-MODULENAME/cellMods ## Default is e3-MODULENAME/cellMods
E3_CELL_PATH?=$(TOP)/cellMods E3_CELL_PATH=$(TOP)/cellMods
## ##
## Allow local file in $(TOP)/configure ## Allow local file in $(TOP)/configure
## local file in $(TOP)/../ ## local file in $(TOP)/../
......
...@@ -19,6 +19,9 @@ class Wrapper: ...@@ -19,6 +19,9 @@ class Wrapper:
self.module_dir = self.path / module_path self.module_dir = self.path / module_path
self.module_dir.mkdir(parents=True) self.module_dir.mkdir(parents=True)
self.config_dir = self.path / "configure"
self.config_dir.mkdir()
self.makefile = self.path / f"{name}.Makefile" self.makefile = self.path / f"{name}.Makefile"
makefile_contents = f""" makefile_contents = f"""
...@@ -50,6 +53,11 @@ include $(E3_REQUIRE_TOOLS)/driver.makefile ...@@ -50,6 +53,11 @@ include $(E3_REQUIRE_TOOLS)/driver.makefile
def add_file(self, name): def add_file(self, name):
(self.module_dir / name).touch() (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="+"): def add_var_to_makefile(self, makefile_var, value, modifier="+"):
with open(self.makefile, "a") as f: with open(self.makefile, "a") as f:
f.write(f"{makefile_var} {modifier}= {value}\n") f.write(f"{makefile_var} {modifier}= {value}\n")
......
...@@ -45,23 +45,23 @@ def test_patch(wrapper): ...@@ -45,23 +45,23 @@ def test_patch(wrapper):
rc, outs, _ = run_make( rc, outs, _ = run_make(
wrapper, wrapper,
"init", "init",
E3_MODULE_VERSION=MODULE_VERSION, module_version=MODULE_VERSION,
) )
assert rc == 0 assert rc == 0
assert "You are in the local source mode" in outs 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 assert rc == 0
with open(db_path, "r") as f: with open(db_path, "r") as f:
db_contents = f.read() db_contents = f.read()
assert 'field(DESC, "OK")' in db_contents assert 'field(DESC, "OK")' in db_contents
assert "Bad" not 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 rc == 0
assert any((wrapper.module_dir).glob("O.*")) 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 rc == 0
assert any((wrapper.path / "cellMods").glob("**/*.db")) assert any((wrapper.path / "cellMods").glob("**/*.db"))
...@@ -134,12 +134,12 @@ def test_updated_dependencies(wrappers): ...@@ -134,12 +134,12 @@ def test_updated_dependencies(wrappers):
rc, *_ = run_make( rc, *_ = run_make(
wrapper_dep, wrapper_dep,
"cellinstall", "cellinstall",
E3_CELL_PATH=cell_path, module_version=old_version,
E3_MODULE_VERSION=old_version, cell_path=cell_path,
) )
assert rc == 0 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 assert rc == 0
new_version = "1.0.0+0" new_version = "1.0.0+0"
...@@ -147,8 +147,8 @@ def test_updated_dependencies(wrappers): ...@@ -147,8 +147,8 @@ def test_updated_dependencies(wrappers):
rc, *_ = run_make( rc, *_ = run_make(
wrapper_dep, wrapper_dep,
"cellinstall", "cellinstall",
E3_CELL_PATH=cell_path, module_version=new_version,
E3_MODULE_VERSION=new_version, cell_path=cell_path,
) )
assert rc == 0 assert rc == 0
...@@ -156,7 +156,7 @@ def test_updated_dependencies(wrappers): ...@@ -156,7 +156,7 @@ def test_updated_dependencies(wrappers):
f"{wrapper_dep.name}_VERSION", new_version, modifier="" 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 assert rc == 0
rc, o, _ = run_ioc_get_output( rc, o, _ = run_ioc_get_output(
......
...@@ -39,6 +39,6 @@ def test_incorrect_module_name(wrappers): ...@@ -39,6 +39,6 @@ def test_incorrect_module_name(wrappers):
module_name = "ADCore" module_name = "ADCore"
wrapper = wrappers.get(name=module_name) 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 rc == 2
assert f"E3_MODULE_NAME '{module_name}' is not valid" in errs assert f"E3_MODULE_NAME '{module_name}' is not valid" in errs
...@@ -40,7 +40,7 @@ def test_version(wrapper, requested, expected, installed): ...@@ -40,7 +40,7 @@ def test_version(wrapper, requested, expected, installed):
wrapper, wrapper,
"clean", "clean",
"cellinstall", "cellinstall",
E3_MODULE_VERSION=version, module_version=version,
) )
assert returncode == 0 assert returncode == 0
......
...@@ -3,6 +3,7 @@ import subprocess ...@@ -3,6 +3,7 @@ import subprocess
import time import time
from pathlib import Path from pathlib import Path
from .conftest import Wrapper
from run_iocsh import IOC from run_iocsh import IOC
EPICS_BASE = os.environ.get("EPICS_BASE") EPICS_BASE = os.environ.get("EPICS_BASE")
...@@ -28,13 +29,17 @@ def set_env_vars(env: dict) -> dict: ...@@ -28,13 +29,17 @@ def set_env_vars(env: dict) -> dict:
return env 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 Attempt to run `make <args>` in the specified path with <kwargs> as environment variables
""" """
test_env = set_env_vars(os.environ.copy()) test_env = set_env_vars(os.environ.copy())
for kw in kwargs: if module_name:
test_env[kw] = kwargs[kw] 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) make_cmd = ["make", "-C", wrapper.path] + list(args)
p = subprocess.Popen( p = subprocess.Popen(
make_cmd, make_cmd,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment