Skip to content
Snippets Groups Projects
Commit 63a318ae authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[ptests] fix warning msg generated for complex enabled_if conditions

Far from perfect, but at least we now generate a correct dune file in such case.
parent 8f68c3d5
No related branches found
No related tags found
No related merge requests found
...@@ -1977,11 +1977,15 @@ let warn_if_not_enabled = ...@@ -1977,11 +1977,15 @@ let warn_if_not_enabled =
let dune_cond_regexp = Str.regexp "^(\\(.*\\))" in let dune_cond_regexp = Str.regexp "^(\\(.*\\))" in
let doublequote_regexp = Str.regexp "\"" in let doublequote_regexp = Str.regexp "\"" in
let dune_var_regexp = Str.regexp "%{" in let dune_var_regexp = Str.regexp "%{" in
let paren_regexp = Str.regexp "[()]" in
let dune_cond_item s = Str.global_replace dune_cond_regexp "\\1" s in let dune_cond_item s = Str.global_replace dune_cond_regexp "\\1" s in
let escaped_cond s = let escaped_cond s =
let s = Str.global_replace dune_var_regexp "\\%{" s in let s = Str.global_replace dune_var_regexp "\\%{" s in
Str.global_replace doublequote_regexp "\\\"" s Str.global_replace doublequote_regexp "\\\"" s
in in
let safe_cond s =
Str.global_replace paren_regexp "\"\\0\"" s
in
fun ~env ~suite fmt enabled_if -> fun ~env ~suite fmt enabled_if ->
if not (StringSet.is_empty enabled_if) then begin if not (StringSet.is_empty enabled_if) then begin
Format.fprintf fmt Format.fprintf fmt
...@@ -2000,7 +2004,7 @@ let warn_if_not_enabled = ...@@ -2000,7 +2004,7 @@ let warn_if_not_enabled =
let pp_enabled fmt cond = let pp_enabled fmt cond =
let cond = dune_cond_item cond in let cond = dune_cond_item cond in
Format.fprintf fmt " (echo \"- %s: \" %s \"\\n\")\n " Format.fprintf fmt " (echo \"- %s: \" %s \"\\n\")\n "
(escaped_cond cond) cond (escaped_cond cond) (safe_cond cond)
in in
let conds = StringSet.elements enabled_if in let conds = StringSet.elements enabled_if in
Format.fprintf fmt Format.fprintf fmt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment