From 93dbc482fac1551044bd24172e76ccb387c83631 Mon Sep 17 00:00:00 2001
From: Basile Desloges <basile.desloges@cea.fr>
Date: Thu, 16 Jul 2020 16:28:26 +0200
Subject: [PATCH] [eacsl:tests] Allow the use of `PTESTS_OPTS` to change the
 test configuration

- The makefile updates `PTESTS_OPTS` instead of `PLUGIN_PTESTS_OPTS` so
  that modifications of `PTESTS_OPTS` by the user are taken into
  account.
- All the test config files are generated at the same time.
- The test dependencies of E-ACSL are added to the target
  `plugins_ptests_config` to be generated along with the main target.
  This in turn allow the user to directly use `ptests.opt` to launch
  tests after compiling the plugin.
---
 src/plugins/e-acsl/Makefile.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/plugins/e-acsl/Makefile.in b/src/plugins/e-acsl/Makefile.in
index 3a372cf0943..f0822e881e7 100644
--- a/src/plugins/e-acsl/Makefile.in
+++ b/src/plugins/e-acsl/Makefile.in
@@ -167,20 +167,27 @@ PLUGIN_TESTS_DIRS := \
 
 PLUGIN_TESTS_LIB := $(EACSL_PLUGIN_DIR)/tests/print.ml
 
-DEV=
+DEV?=
 ifeq ("$(DEV)","yes")
-  EACSL_TEST_CONFIG=dev
+  EACSL_TEST_CONFIG:=dev
 else
   EACSL_TEST_CONFIG:=ci
 endif
-PLUGIN_PTESTS_OPTS:=-config $(EACSL_TEST_CONFIG)
+# Prepend PTESTS_OPTS with the test config to use. If the user-provided
+# PTESTS_OPTS variable contains another -config instruction, then it will be
+# prioritized over the one selected by the Makefile.
+E_ACSL_TESTS E_ACSL_DEFAULT_TESTS: override PTESTS_OPTS:=-config $(EACSL_TEST_CONFIG) $(PTESTS_OPTS)
 
 TEST_DEPENDENCIES:= \
 	$(EACSL_PLUGIN_DIR)/tests/ptests_config \
-	$(EACSL_PLUGIN_DIR)/tests/test_config_$(EACSL_TEST_CONFIG) \
+	$(EACSL_PLUGIN_DIR)/tests/test_config_ci \
+	$(EACSL_PLUGIN_DIR)/tests/test_config_dev \
 	$(EACSL_PLUGIN_DIR)/tests/print.cmxs \
 	$(EACSL_PLUGIN_DIR)/tests/print.cmo
 
+# Add the test dependencies to the test targets, but also to
+# `plugins_ptests_config` so that they are built along with the main target.
+plugins_ptests_config: $(TEST_DEPENDENCIES)
 E_ACSL_TESTS E_ACSL_DEFAULT_TESTS: $(TEST_DEPENDENCIES)
 tests:: $(TEST_DEPENDENCIES)
 
-- 
GitLab