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

All tests working again

parent 40e25b9b
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......@@ -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
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