Add an option to disable test deps being given a test constraint.  This works around an odd behavior in opam install -t which installs, and runs, test deps for every dependency rather than just the one being installed
1 files changed, 30 insertions(+), 8 deletions(-)

M src/hll/hll.ml
M src/hll/hll.ml +30 -8
@@ 29,8 29,18 @@ module Cmdline = struct
       let doc = "Path to pds config for this repo, pds.conf by default" in
       C.Arg.(value & opt file "pds.conf" & info ["pds"] ~docv:"FILE" ~doc)
     in
+    let test_deps_as_regular_deps =
+      let doc = "Test deps will not get a 'test' constraint, workaround for opam install -t bug" in
+      C.Arg.(value & flag & info ["test-deps-as-regular-deps"] ~doc)
+    in
     let doc = "generate an opam package from a pds and an hll config" in
-    C.Term.(const generate_pkg $ opam_dir $ tag $ pins_file $ hll_conf $ pds_conf,
+    C.Term.(const generate_pkg $
+            opam_dir $
+            tag $
+            pins_file $
+            hll_conf $
+            pds_conf $
+            test_deps_as_regular_deps,
             info "generate" ~doc)
 
   let default_cmd =

          
@@ 390,7 400,7 @@ module Generate_io = struct
           table
           [])
 
-    let read fname =
+    let read test_deps_as_regular_deps fname =
       let pds_conf = Toml.Parser.(from_filename fname |> unsafe) in
       let srcs =
         value_opt

          
@@ 407,10 417,16 @@ module Generate_io = struct
       let test_deps = String_set.of_list (list_deps tests) in
       (* Those deps that are just in the test section *)
       let test_only_deps = String_set.diff test_deps deps in
-      { deps = deps
-      ; test_deps = test_only_deps
-      ; targets = targets
-      }
+      if not test_deps_as_regular_deps then
+        { deps = deps
+        ; test_deps = test_only_deps
+        ; targets = targets
+        }
+      else
+        { deps = String_set.union deps test_only_deps
+        ; test_deps = String_set.empty
+        ; targets = targets
+        }
 
     let external_deps t = String_set.diff t.deps t.targets
 

          
@@ 479,11 495,17 @@ let maybe_load_pins = function
   | Some file -> Generate_io.Pins.read file
   | None -> Generate_io.Pins.empty
 
-let generate_pkg opam_dir (tag_opt : string option) pins_file_opt hll_conf pds_conf =
+let generate_pkg
+    opam_dir
+    (tag_opt : string option)
+    pins_file_opt
+    hll_conf
+    pds_conf
+    test_deps_as_regular_deps =
   let tag = maybe_load_tag tag_opt in
   let pins = maybe_load_pins pins_file_opt in
   let hll_conf = Generate_io.Hll_conf.read hll_conf in
-  let pds_conf = Generate_io.Pds_conf.read pds_conf in
+  let pds_conf = Generate_io.Pds_conf.read test_deps_as_regular_deps pds_conf in
   let gen_t =
     Generate.({ tag = tag
               ; url_protocol = hll_conf.Generate_io.Hll_conf.url_protocol