From 88154b18ccc8b20168e7f802ff25a5e4564ce8f1 Mon Sep 17 00:00:00 2001
From: "Lucas A. M. Magalhaes" <lucas.magalhaes@ess.eu>
Date: Wed, 17 Aug 2022 13:45:40 +0200
Subject: [PATCH] Set custom E3_MODULES_PATH for test target

The test rule for e3 modules actually does a cellinstall and run the
tests inside this temporary installation. The cellinstall needs to
overwrite some path variables to work this variables were not accessible
through the test rule as they are just changed if cell is on
MAKECMDGOALS. This made impossible to use the standard path variables
inside module's custom test rules.

To fix it the same mechanism used in cellinstall is implemented for test
and the variables paths are now overwritten. This makes possible ie. to
use E3_MODULES_INSTALL_LOCATION_BIN inside custom test rules.

This commit also introduces an unwanted behavior. As the test rule is
now overwriting the standard path variables it cannot longer be along
with the install rule. For example, running `make test install` will
install the module inside the test dir. This is a known issue for
cellinstall as well and a restructure of the Makefile code should be
made to isolate the rules.
---
 configure/E3/CONFIG      | 2 +-
 configure/E3/CONFIG_TEST | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure/E3/CONFIG b/configure/E3/CONFIG
index 0a8d8fed..6f5efa83 100644
--- a/configure/E3/CONFIG
+++ b/configure/E3/CONFIG
@@ -9,9 +9,9 @@ include $(EPICS_BASE)/configure/CONFIG_BASE_VERSION
 include $(REQUIRE_CONFIG)/CONFIG_REQUIRE
 include $(REQUIRE_CONFIG)/CONFIG_SHELL
 include $(REQUIRE_CONFIG)/CONFIG_CELL
+include $(REQUIRE_CONFIG)/CONFIG_TEST
 include $(REQUIRE_CONFIG)/CONFIG_E3_PATH
 include $(REQUIRE_CONFIG)/CONFIG_E3_MAKEFILE
-include $(REQUIRE_CONFIG)/CONFIG_TEST
 include $(REQUIRE_CONFIG)/CONFIG_EPICS
 include $(REQUIRE_CONFIG)/CONFIG_DKMS
 include $(REQUIRE_CONFIG)/CONFIG_EXPORT
diff --git a/configure/E3/CONFIG_TEST b/configure/E3/CONFIG_TEST
index 0b04b6b3..473f4381 100644
--- a/configure/E3/CONFIG_TEST
+++ b/configure/E3/CONFIG_TEST
@@ -9,3 +9,7 @@ EXPORT_VARS+=TEMP_CELL_PATH
 VARS_EXCLUDES+=TEST_DIR
 VARS_EXCLUDES+=RMDIR
 VARS_EXCLUDES+=TEMP_CELL_PATH
+
+ifneq (,$(findstring test,$(MAKECMDGOALS)))
+  E3_MODULES_PATH=$(TEMP_CELL_PATH)/$(notdir $(EPICS_BASE))/require-$(E3_REQUIRE_VERSION)
+endif
-- 
GitLab