From eb26bdfb37ca3178fc217b9eec893daa0d7d37eb Mon Sep 17 00:00:00 2001
From: Patrick Baudin <patrick.baudin@cea.fr>
Date: Mon, 19 Oct 2020 14:15:04 +0200
Subject: [PATCH] [Ptests] generalize the use of the current @DEFAULT_OPTIONS@
 into EXECNOW directives

---
 ptests/ptests.ml | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/ptests/ptests.ml b/ptests/ptests.ml
index 6d18aa45e7d..ce24ba7a4db 100644
--- a/ptests/ptests.ml
+++ b/ptests/ptests.ml
@@ -20,10 +20,6 @@
 (*                                                                        *)
 (**************************************************************************)
 
-(** the options to launch the toplevel with if the test file is not
-     annotated with test options *)
-let default_options = "-journal-disable -check"
-
 module Filename = struct
   include Filename
   let concat =
@@ -548,7 +544,7 @@ type config =
 
 let default_macros () = Macros.add_list 
   [ "PLUGIN", "" ;
-    "DEFAULT_OPTIONS", default_options;
+    "DEFAULT_OPTIONS", "-journal-disable -check"; (* the options automatically added by the use of @frama-c@ in CMD and EXECNOW command.  *)
     "OPTIONS", "";
   ] Macros.empty
 
@@ -609,7 +605,7 @@ let scan_execnow ~once dir ex_timeout (s:string) =
 let current_default_toplevel = ref "frama-c"
 let current_default_log = ref []
 let current_default_cmds =
-  ref ["frama-c",default_options,[], Macros.empty, ""]
+  ref ["frama-c", "@DEFAULT_OPTIONS@", [], Macros.empty, ""]
 
 let make_custom_opts =
   let space = Str.regexp " " in
@@ -964,6 +960,7 @@ let basic_command_string command =
     ] macros in
 
   let toplevel, macros= if contains_framac_macro command.toplevel then
+     (* in such a case, OPTIONS are automatically added at the end of the current CMD *)
      let toplevel = String.concat " " [command.toplevel ; "@OPTIONS@"]
      and macros =
        Macros.add_list [
@@ -974,10 +971,7 @@ let basic_command_string command =
     command.toplevel, macros
   in
 
-  let toplevel =
-    Macros.expand macros toplevel
-  in
-  let raw_command = toplevel in
+  let raw_command = Macros.expand macros toplevel in
   if command.timeout = "" then raw_command
   else "ulimit -t " ^ command.timeout ^ " && " ^ raw_command
 
-- 
GitLab