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

Added test for header installation

parent 6281688b
No related branches found
No related tags found
1 merge request!67E3-665: Add tests for KEEP_HEADER_SUBDIRS
import re
from pathlib import Path
import pytest
from .utils import TEST_MODULE_NAME, run_make
from .utils import TEST_MODULE_NAME, get_env_var, run_make
MODULE_VERSION = "0.0.0+0"
MODULE_VERSION_NO_BUILD = "0.0.0"
......@@ -56,7 +57,7 @@ def test_patch(wrapper):
E3_MODULE_VERSION=MODULE_VERSION,
)
assert rc == 0
assert "You are in the local source mode" in outs.decode("utf-8")
assert "You are in the local source mode" in outs
rc, _, _ = run_make(wrapper, "patch", E3_MODULE_VERSION=MODULE_VERSION)
assert rc == 0
......@@ -85,7 +86,7 @@ def test_missing_dbd_file(wrapper):
assert rc == 2
assert re.search(
RE_MISSING_FILE.format(filename=re.escape("../nonexistent.dbd")),
errs.decode("utf-8"),
errs,
)
......@@ -100,7 +101,7 @@ def test_missing_source_file(wrapper):
assert rc == 2
assert re.search(
RE_MISSING_FILE.format(filename=re.escape("nonexistent.o")),
errs.decode("utf-8"),
errs,
)
......@@ -111,3 +112,26 @@ def test_missing_requirement(wrapper):
rc, _, errs = run_make(wrapper, "build")
assert rc == 2
assert "REQUIRED module 'foo' version '' does not exist" in errs.decode("utf-8")
def test_header_install_location(wrapper):
subdir = wrapper / TEST_MODULE_NAME / "db" / "subdir"
subdir.mkdir(parents=True)
extensions = ["h", "hpp", "hxx", "hh"]
with open(wrapper / f"{TEST_MODULE_NAME}.Makefile", "a") as f:
for ext in extensions:
f.write(f"HEADERS += db/subdir/header.{ext}\n")
f.write("KEEP_HEADER_SUBDIRS += db\n")
for extension in extensions:
with open(subdir / f"header.{extension}", "w") as f:
pass
rc, _, _ = run_make(wrapper, "cellinstall")
assert rc == 0
cell_path = get_env_var(wrapper, "E3_MODULES_INSTALL_LOCATION")
for ext in extensions:
assert (Path(cell_path) / "include" / "subdir" / f"header.{ext}").is_file()
......@@ -11,7 +11,7 @@ from .utils import run_make
def test_loc(wrapper):
rc, _, errs = run_make(wrapper, "build", E3_MODULE_SRC_PATH="test-loc")
assert rc == 2
assert 'Local source mode "-loc" has been deprecated' in errs.decode("utf-8")
assert 'Local source mode "-loc" has been deprecated' in errs
def test_sitelibs(wrapper):
......@@ -34,11 +34,11 @@ include $(REQUIRE_CONFIG)/RULES_DEV
)
rc, _, errs = run_make(wrapper, "build")
assert rc == 2
assert "RULES_E3 should only be loaded from RULES_SITEMODS" in errs.decode("utf-8")
assert "RULES_E3 should only be loaded from RULES_SITEMODS" in errs
def test_incorrect_module_name(wrapper):
module_name = "ADCore"
rc, _, errs = run_make(wrapper, "build", E3_MODULE_NAME=module_name)
assert rc == 2
assert f"E3_MODULE_NAME '{module_name}' is not valid" in errs.decode("utf-8")
assert f"E3_MODULE_NAME '{module_name}' is not valid" in errs
......@@ -49,12 +49,27 @@ def run_make(path, *args, **kwargs):
test_env[kw] = kwargs[kw]
make_cmd = ["make", "-C", path] + list(args)
p = subprocess.Popen(
make_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=test_env
make_cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=test_env,
encoding="utf-8",
)
outs, errs = p.communicate()
return p.returncode, outs, errs
def get_env_var(path, var: str):
"""
Fetch an environment variable from the module build environment
"""
_, out, _ = run_make(path, "cellvars")
for line in out.split("\n"):
if line.startswith(var):
return line.split("=")[1].strip()
assert False
def run_ioc_get_output(version, cell_path):
"""
Run an IOC and try to load the test module
......
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