From 9770f372eea6ba8898f5c8283bffb35cadb3282a Mon Sep 17 00:00:00 2001
From: Patrick Baudin <patrick.baudin@cea.fr>
Date: Fri, 29 Jul 2022 16:13:17 +0200
Subject: [PATCH] [tests] access to the local cache wp

---
 tests/dune                    | 3 +++
 tests/set-path-to-wp-cache.sh | 4 ++++
 tests/test_config             | 6 +++++-
 3 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 tests/dune
 create mode 100755 tests/set-path-to-wp-cache.sh

diff --git a/tests/dune b/tests/dune
new file mode 100644
index 0000000..0f0ac39
--- /dev/null
+++ b/tests/dune
@@ -0,0 +1,3 @@
+(rule
+ (target "path-to-wp-cache")
+ (action (run %{dep:./set-path-to-wp-cache.sh})))
diff --git a/tests/set-path-to-wp-cache.sh b/tests/set-path-to-wp-cache.sh
new file mode 100755
index 0000000..faea381
--- /dev/null
+++ b/tests/set-path-to-wp-cache.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+pwd -P | sed 's:\(.*\)/_build/[^/]*\(/.*$\):\1\2/wp-cache:' > path-to-wp-cache
+echo "MetaACSL: using WP cache dir:"
+cat path-to-wp-cache
diff --git a/tests/test_config b/tests/test_config
index 213b04d..5aa5875 100644
--- a/tests/test_config
+++ b/tests/test_config
@@ -1,5 +1,9 @@
+# note: the file @WP_CACHE@ must contain an absolute path to the source
+#       worktree 'tests/wp-cache'. This is done in a rule of 'tests/dune' file.
+MACRO: WP_CACHE ../../../tests/path-to-wp-cache
+
 MACRO: META -meta
-MACRO: WP -then-last -wp -wp-timeout 1 -wp-par 1 -wp-msg-key shell  -wp-cache update -wp-session @PTEST_SUITE_DIR@/../wp-cache
+MACRO: WP -then-last -wp -wp-timeout 1 -wp-par 1 -wp-msg-key shell  -wp-cache update -wp-session=%{read:@WP_CACHE@}
 MACRO: PRINT -then-last -print
 
 MACRO: EVA_PLUGINS eva,scope,inout variadic
-- 
GitLab