diff --git a/tests/test_e3.py b/tests/test_e3.py index 7e7390b051de83d74029e85101ae7e8433609ea6..a02e16725b9ae93a4bd23a9c93176b91ebe53233 100644 --- a/tests/test_e3.py +++ b/tests/test_e3.py @@ -13,8 +13,11 @@ def test_sitelibs(wrappers): wrapper = wrappers.get() with open(wrapper.path / "Makefile", "w") as f: f.write( - """ + f""" TOP:=$(CURDIR) + +E3_MODULE_NAME:={wrapper.name} + include $(REQUIRE_CONFIG)/RULES_E3 include $(REQUIRE_CONFIG)/RULES_CELL include $(REQUIRE_CONFIG)/DEFINES_FT diff --git a/tests/test_versions.py b/tests/test_versions.py index 032028cf1f38c4e220613ac567a74cefbabd4eb5..c0d583d403293723db9c90b5d77a146cd18f5069 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -2,17 +2,12 @@ import re import pytest -from .utils import TEST_MODULE_NAME, run_ioc_get_output, run_make +from .utils import run_ioc_get_output, run_make -RE_MODULE_LOADED = f"Loaded {TEST_MODULE_NAME} version {{version}}" -RE_MODULE_NOT_LOADED = f"Module {TEST_MODULE_NAME} (not available|version {{required}} not available|version {{required}} not available \\(but other versions are available\\))" +RE_MODULE_LOADED = "Loaded {module} version {version}" +RE_MODULE_NOT_LOADED = "Module {module} (not available|version {required} not available|version {required} not available \\(but other versions are available\\))" -@pytest.mark.parametrize( - "wrappers", - [{"templates": "", "sources": "", "dbds": "test.dbd", "headers": ""}], - indirect=True, -) @pytest.mark.parametrize( "requested, expected, installed", [ @@ -39,8 +34,7 @@ RE_MODULE_NOT_LOADED = f"Module {TEST_MODULE_NAME} (not available|version {{requ ("", "0.1.0+0", ["0.1.0", "1.0.0-rc1"]), ], ) -def test_version(wrappers, requested, expected, installed): - wrapper = wrappers.get() +def test_version(wrapper, requested, expected, installed): for version in installed: returncode, _, _ = run_make( wrapper, @@ -50,13 +44,20 @@ def test_version(wrappers, requested, expected, installed): ) assert returncode == 0 - rc, o, e = run_ioc_get_output(requested, wrapper / "cellMods") + rc, o, _ = run_ioc_get_output(wrapper.name, requested, wrapper.path / "cellMods") if expected: - match = re.search(RE_MODULE_LOADED.format(version=re.escape(expected)), o) + match = re.search( + RE_MODULE_LOADED.format(module=wrapper.name, version=re.escape(expected)), o + ) assert rc == 0 assert match else: - match = re.search(RE_MODULE_NOT_LOADED.format(required=re.escape(requested)), o) + match = re.search( + RE_MODULE_NOT_LOADED.format( + module=wrapper.name, required=re.escape(requested) + ), + o, + ) assert match assert rc != 0 diff --git a/tests/utils.py b/tests/utils.py index 5e8c26d32f52300cdbc6f60294c22f1f05cecd06..909f15b232084f486e6b9d92706778903c405303 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -2,14 +2,9 @@ import os import subprocess import time from pathlib import Path -from random import choice -from string import ascii_lowercase from run_iocsh import IOC -# Random module name -TEST_MODULE_NAME = "test_mod_" + "".join(choice(ascii_lowercase) for _ in range(16)) - EPICS_BASE = os.environ.get("EPICS_BASE") E3_REQUIRE_VERSION = os.environ.get("E3_REQUIRE_VERSION") @@ -30,10 +25,6 @@ def set_env_vars(env: dict) -> dict: REQUIRE_CONFIG = f"{E3_REQUIRE_LOCATION}/configure" env["REQUIRE_CONFIG"] = REQUIRE_CONFIG - env["E3_MODULE_NAME"] = TEST_MODULE_NAME - env["E3_MODULE_SRC_PATH"] = TEST_MODULE_NAME - env["E3_MODULE_MAKEFILE"] = f"{TEST_MODULE_NAME}.Makefile" - # Add a default version env["E3_MODULE_VERSION"] = "0.0.0" @@ -70,10 +61,11 @@ def get_env_var(wrapper, var: str): return "" -def run_ioc_get_output(version, cell_path): +def run_ioc_get_output(module, version, cell_path): """ Run an IOC and try to load the test module """ - with IOC("-r", f"{TEST_MODULE_NAME},{version}", "-l", cell_path) as ioc: + print(f"run_ioc_get_output {module} {version} {cell_path}") + with IOC("-r", f"{module},{version}", "-l", cell_path) as ioc: time.sleep(1) return ioc.proc.returncode, ioc.outs, ioc.errs