From 476480eb960a6d10f6f46fbbc5dc1fa5a0c79b21 Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Wed, 26 Oct 2022 14:53:12 +0200
Subject: [PATCH] [ptests] fix handling of LIBRARY directive

you don't want to update PTEST_PLUGIN if you have a LIBRARY...
---
 tools/ptests/ptests.ml | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/ptests/ptests.ml b/tools/ptests/ptests.ml
index a213f47b002..bc6cbf9cc86 100644
--- a/tools/ptests/ptests.ml
+++ b/tools/ptests/ptests.ml
@@ -884,15 +884,17 @@ end = struct
       dc_libs = Some l;
       dc_macros = Macros.add_list ["PTEST_LIBS", s] current.dc_macros }
 
-  let config_gen var_name =
+  let config_gen var_name update_field =
     fun ~drop:_ ~file ~dir:_ s current ->
     let s = Macros.expand ~file current.dc_macros s in
     let l = split_list s in
-    { current with dc_plugin = Some l ;
-                   dc_macros = Macros.add_list [var_name, s] current.dc_macros }
+    let current = update_field current (Some l) in
+    { current with dc_macros = Macros.add_list [var_name, s] current.dc_macros }
 
-  let config_plugin = config_gen "PTEST_PLUGIN"
-  let config_library = config_gen "PTEST_LIBRARY"
+  let config_plugin =
+    config_gen "PTEST_PLUGIN" (fun c dc_plugin->{ c with dc_plugin })
+  let config_library =
+    config_gen "PTEST_LIBRARY" (fun c dc_library -> { c with dc_library })
 
   let config_module macro_name ~drop:_ ~file ~dir:_ s current =
     let s = Macros.expand ~file current.dc_macros s in
-- 
GitLab