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

Merge branch 'e3_311' into 'master'

E3-311: Check that wrappers have the correct RULES file

See merge request e3/e3-require!42
parents 02dfce1a d6b7f282
No related branches found
No related tags found
1 merge request!42E3-311: Check that wrappers have the correct RULES file
Pipeline #85563 passed
.PHONY: consistency_checks
consistency_checks: module_name_check sitemods_check loc-check
# Check that the module name satisfies a few conditions before we go on.
module_name_check:
ifneq ($(shell echo $(E3_MODULE_NAME) | grep -q '^[a-z_][a-z0-9_]*$$' ; echo $$?),0)
$(error E3_MODULE_NAME '$(E3_MODULE_NAME)' is not valid. It should consist only of lowercase letters, numbers, and underscores.)
endif
# Check that a module is including RULES_SITEMODS instead of RULES_SITEAPPS or manually including RULES_E3
.PHONY: sitemods_check
sitemods_check:
ifeq ($(filter RULES_SITEMODS,$(notdir $(MAKEFILE_LIST))),)
$(error RULES_E3 should only be loaded from RULES_SITEMODS)
endif
# Check that e3 wrappers are using EPICS_MODULE_TAG to manage local source mode
.PHONU: loc-check
loc-check:
ifneq (,$(findstring -loc,$(E3_MODULE_SRC_PATH)))
$(error DEPRECATED: Local source mode "-loc" has being deprecated. Please comment out the EPICS_MODULE_TAG to use local source mode.)
endif
......@@ -7,10 +7,10 @@
default: help
# # help is defined in
# # help is defined in
# # https://gist.github.com/rcmachado/af3db315e31383502660
help:
$(info --------------------------------------- )
$(info --------------------------------------- )
$(info Available targets)
$(info --------------------------------------- )
$(QUIET) awk '/^[a-zA-Z\-\_0-9]+:/ { \
......@@ -23,7 +23,7 @@ help:
print $$1 "\t" helpMsg; \
} \
{ helpMsg = $$0 }' \
$(MAKEFILE_LIST) | column -ts:
$(MAKEFILE_LIST) | column -ts:
......@@ -63,7 +63,7 @@ db_internal: conf
$(QUIET) $(E3_MODULE_MAKE_CMDS) db_internal
## Clean, build, and install the current module
rebuild: clean build install
rebuild: clean build install
## Deletes temporary build files
clean: conf
......@@ -73,34 +73,25 @@ clean: conf
all: init patch rebuild
# Copy $(E3_MODULE_MAKEFILE) into $(E3_MODULE_SRC_PATH)
conf: module_name_check
include $(REQUIRE_CONFIG)/RULES_CHECKS
conf: consistency_checks
$(QUIET) install -p -m 644 $(TOP)/$(E3_MODULE_MAKEFILE) $(E3_MODULE_SRC_PATH)/
# We should check that the module name satisfies a few conditions before we go on.
module_name_check:
ifneq ($(shell echo $(E3_MODULE_NAME) | grep -q '^[a-z_][a-z0-9_]*$$' ; echo $$?),0)
$(error E3_MODULE_NAME '$(E3_MODULE_NAME)' is not valid. It should consist only of lowercase letters, numbers, and underscores.)
endif
.PHONY: init git-submodule-sync $(E3_MODULE_SRC_PATH) checkout
ifeq (,$(strip $(EPICS_MODULE_TAG)))
E3_LOCAL_SOURCE:=1
endif
ifneq (,$(findstring -loc,$(E3_MODULE_SRC_PATH)))
$(warning DEPRECATED: Local source mode "-loc" is being deprecated. Please comment out the EPICS_MODULE_TAG to use local source mode.)
E3_LOCAL_SOURCE:=1
endif
ifeq ($(E3_LOCAL_SOURCE),1)
init:
init:
$(QUIET) echo ">> You are in the local source mode."
$(QUIET) echo ">> Nothing happens."
checkout:
else
## Syncs and checks out the tag $(EPICS_MODULE_TAG) for the submodule
## Syncs and checks out the tag $(EPICS_MODULE_TAG) for the submodule
init: git-submodule-sync $(E3_MODULE_SRC_PATH) checkout
......@@ -108,13 +99,12 @@ git-submodule-sync:
$(QUIET) git submodule sync
$(E3_MODULE_SRC_PATH):
$(E3_MODULE_SRC_PATH):
$(QUIET) $(git_update)
checkout:
checkout:
cd $(E3_MODULE_SRC_PATH) && git checkout $(EPICS_MODULE_TAG)
endif
......@@ -13,8 +13,18 @@ def wrapper(tmpdir, request):
Note that a number of necessary variables are expected to be present in the environment
"""
try:
params = request.param
except AttributeError:
params = {}
wrapper_dir = Path(tmpdir / "wrapper")
test_dir = wrapper_dir / TEST_MODULE_NAME
TEST_MODULE_PATH = (
TEST_MODULE_NAME
if "E3_MODULE_SRC_PATH" not in params
else params["E3_MODULE_SRC_PATH"]
)
test_dir = wrapper_dir / TEST_MODULE_PATH
test_dir.mkdir(parents=True)
config_file = """
......@@ -40,9 +50,10 @@ HEADERS += {headers}
f.write(config_file)
make_vars = {"templates": "", "sources": "", "dbds": "", "headers": ""}
make_vars.update(**request.param)
make_vars.update(**params)
with open(wrapper_dir / f"{TEST_MODULE_NAME}.Makefile", "w") as f:
f.write(module_makefile.format(**make_vars))
with open(wrapper_dir / TEST_MODULE_NAME / "test.dbd", "w") as f:
with open(wrapper_dir / TEST_MODULE_PATH / "test.dbd", "w") as f:
pass
yield wrapper_dir
import pytest
from .utils import run_make
@pytest.mark.parametrize(
"wrapper",
[{"E3_MODULE_SRC_PATH": "test-loc"}],
indirect=True,
)
def test_loc(wrapper):
rc, _, _ = run_make(wrapper, "build", E3_MODULE_SRC_PATH="test-loc")
assert rc == 2
def test_sitelibs(wrapper):
# Overwrite the default makefile
with open(wrapper / "Makefile", "w") as f:
f.write(
"""
TOP:=$(CURDIR)
include $(REQUIRE_CONFIG)/CONFIG
include $(REQUIRE_CONFIG)/RULES_E3
include $(REQUIRE_CONFIG)/DEFINES_FT
include $(REQUIRE_CONFIG)/RULES_PATCH
include $(REQUIRE_CONFIG)/RULES_E3_SITELIBS
include $(REQUIRE_CONFIG)/RULES_VLIBS
include $(REQUIRE_CONFIG)/RULES_VARS
"""
)
rc, _, _ = run_make(wrapper, "build")
assert rc == 2
def test_incorrect_module_name(wrapper):
rc, _, _ = run_make(wrapper, "build", E3_MODULE_NAME="ADCore")
assert rc == 2
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