From bf1f15106f2bbdb18745f3ff118177bbd21cf1ec Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Mon, 25 Feb 2019 18:31:12 +0100
Subject: [PATCH] [ptests] Allows arobases in options of ptests.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Juste use `@@` as in `Format` 😛
---
 ptests/ptests.ml     | 22 +++++++++++++---------
 tests/rte/twofunc3.c |  2 +-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/ptests/ptests.ml b/ptests/ptests.ml
index 61d3b38decb..d99f688a4ac 100644
--- a/ptests/ptests.ml
+++ b/ptests/ptests.ml
@@ -493,7 +493,7 @@ end = struct
 
 end
 
-let macro_regex = Str.regexp "\\([^@]*\\)@\\([^@]+\\)@\\(.*\\)"
+let macro_regex = Str.regexp "\\([^@]*\\)@\\([^@]*\\)@\\(.*\\)"
 
 type execnow =
     {
@@ -585,15 +585,19 @@ let replace_macros macros s =
       let rest = Str.matched_group 3 s in
       let new_n = Str.group_end 1 in
       let n, new_s =
-        try
-          if !verbosity >= 2 then lock_printf "macro is %s\n%!" macro;
-          let replacement =  StringMap.find macro macros in
-          if !verbosity >= 1 then
-            lock_printf "replacement for %s is %s\n%!" macro replacement;
-          new_n,
-          String.sub s 0 n ^ start ^ replacement ^ rest
-        with
+        if macro = "" then begin
+          new_n + 1, String.sub s 0 new_n ^ "@" ^ rest
+        end else begin
+          try
+            if !verbosity >= 2 then lock_printf "macro is %s\n%!" macro;
+            let replacement =  StringMap.find macro macros in
+            if !verbosity >= 1 then
+              lock_printf "replacement for %s is %s\n%!" macro replacement;
+            new_n,
+            String.sub s 0 n ^ start ^ replacement ^ rest
+          with
           | Not_found -> Str.group_end 2 + 1, s
+        end
       in
        if !verbosity >= 2 then lock_printf "new string is %s\n%!" new_s;
       let new_acc = ptest_file_matched, new_s in
diff --git a/tests/rte/twofunc3.c b/tests/rte/twofunc3.c
index b7102aaf708..fab3e66a5ab 100644
--- a/tests/rte/twofunc3.c
+++ b/tests/rte/twofunc3.c
@@ -1,6 +1,6 @@
 /* run.config
    EXECNOW: make -s @PTEST_DIR@/rte_api/rte_get_annot.cmxs
-   OPT: -load-module @PTEST_DIR@/rte_api/rte_get_annot -journal-disable
+   OPT: -rte-select @@all -load-module @PTEST_DIR@/rte_api/rte_get_annot -journal-disable
 */
 
 
-- 
GitLab