From 40bca6d9b3b3ccda9a90dec01ae07cb5f2bd6c6a Mon Sep 17 00:00:00 2001
From: Simon Rose <simon.rose@ess.eu>
Date: Fri, 18 Jun 2021 13:08:43 +0200
Subject: [PATCH] Initial build test

---
 tests/test_build/Makefile                     | 17 +++++++++++++++
 tests/test_build/wrapper/Makefile             | 21 +++++++++++++++++++
 tests/test_build/wrapper/build.Makefile       |  6 ++++++
 tests/test_build/wrapper/build/database.db    |  3 +++
 .../wrapper/patch/Site/0.0.0+0/apply.p0.patch |  0
 .../patch/Site/0.0.0-dont-apply.p0.patch      |  0
 .../patch/Site/0.0.0/dont-apply.p0.patch      |  0
 7 files changed, 47 insertions(+)
 create mode 100644 tests/test_build/Makefile
 create mode 100644 tests/test_build/wrapper/Makefile
 create mode 100644 tests/test_build/wrapper/build.Makefile
 create mode 100644 tests/test_build/wrapper/build/database.db
 create mode 100644 tests/test_build/wrapper/patch/Site/0.0.0+0/apply.p0.patch
 create mode 100644 tests/test_build/wrapper/patch/Site/0.0.0-dont-apply.p0.patch
 create mode 100644 tests/test_build/wrapper/patch/Site/0.0.0/dont-apply.p0.patch

diff --git a/tests/test_build/Makefile b/tests/test_build/Makefile
new file mode 100644
index 00000000..9a67252d
--- /dev/null
+++ b/tests/test_build/Makefile
@@ -0,0 +1,17 @@
+
+.PHONY: default
+default: test
+
+.PHONY: test
+test: check_env
+	${MAKE} -C wrapper init
+	${MAKE} -C wrapper clean
+	${MAKE} -C wrapper patch
+	${MAKE} -C wrapper cellinstall
+
+.PHONY: check_env
+check_env: guard-EPICS_BASE guard-E3_REQUIRE_VERSION
+	@#$(or $(wildcard ${EPICS_BASE}/require/${E3_REQUIRE_VERSION}/bin/setE3Env.bash), $(error setE3Env.bash not found. Please check your version of base and require.))
+
+guard-%:
+	@#$(or ${$*}, $(error $* is not set))
diff --git a/tests/test_build/wrapper/Makefile b/tests/test_build/wrapper/Makefile
new file mode 100644
index 00000000..b306bbdc
--- /dev/null
+++ b/tests/test_build/wrapper/Makefile
@@ -0,0 +1,21 @@
+TOP:=$(CURDIR)
+
+E3_REQUIRE_LOCATION := $(EPICS_BASE)/require/$(E3_REQUIRE_VERSION)
+REQUIRE_CONFIG := $(E3_REQUIRE_LOCATION)/configure
+
+# To configure the modules
+EPICS_MODULE_NAME:=build
+E3_MODULE_VERSION:=0.0.0
+E3_MODULE_NAME:=$(EPICS_MODULE_NAME)
+E3_MODULE_SRC_PATH:=$(EPICS_MODULE_NAME)
+E3_MODULE_MAKEFILE:=$(EPICS_MODULE_NAME).Makefile
+
+include $(REQUIRE_CONFIG)/CONFIG
+include $(REQUIRE_CONFIG)/RULES_SITEMODS
+
+ifeq ($(strip $(E3_REQUIRE_VERSION)),3.4.1)
+db: conf
+	$(QUIET) $(E3_MODULE_MAKE_CMDS) db
+endif
+
+hdrs:
diff --git a/tests/test_build/wrapper/build.Makefile b/tests/test_build/wrapper/build.Makefile
new file mode 100644
index 00000000..c808a249
--- /dev/null
+++ b/tests/test_build/wrapper/build.Makefile
@@ -0,0 +1,6 @@
+where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+include $(E3_REQUIRE_TOOLS)/driver.makefile
+
+db:
+
+.PHONY: db
\ No newline at end of file
diff --git a/tests/test_build/wrapper/build/database.db b/tests/test_build/wrapper/build/database.db
new file mode 100644
index 00000000..1806ff63
--- /dev/null
+++ b/tests/test_build/wrapper/build/database.db
@@ -0,0 +1,3 @@
+record(ai, "TEST") {
+    
+}
\ No newline at end of file
diff --git a/tests/test_build/wrapper/patch/Site/0.0.0+0/apply.p0.patch b/tests/test_build/wrapper/patch/Site/0.0.0+0/apply.p0.patch
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/test_build/wrapper/patch/Site/0.0.0-dont-apply.p0.patch b/tests/test_build/wrapper/patch/Site/0.0.0-dont-apply.p0.patch
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/test_build/wrapper/patch/Site/0.0.0/dont-apply.p0.patch b/tests/test_build/wrapper/patch/Site/0.0.0/dont-apply.p0.patch
new file mode 100644
index 00000000..e69de29b
-- 
GitLab