From d13411b0bcc9dd40619fd226e6502d34f2b210e6 Mon Sep 17 00:00:00 2001 From: Alpha DIALLO Date: Thu, 2 Feb 2023 16:52:11 +0100 Subject: [PATCH] Clean the code and fix the tests output Signed-off-by: Alpha DIALLO --- bin/describe.ml | 21 +++++--------- .../exclude-internal-deps.t/run.t | 12 ++++++-- .../external-lib-deps/simple-pps.t/run.t | 29 ++++++++++++------- .../external-lib-deps/simple.t/run.t | 7 ++++- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/bin/describe.ml b/bin/describe.ml index eeaa824bc01..21683fa9165 100644 --- a/bin/describe.ml +++ b/bin/describe.ml @@ -627,22 +627,15 @@ module External_lib_deps = struct let to_dyn t = let open Dyn in - let names = - if t.kind = Kind.Library then ("name", String (List.hd t.names)) - else ("names", (list string) t.names) - in - let package = - match t.package with - | Some p -> - [ ("package", String (p |> Package.name |> Package.Name.to_string)) ] - | None -> [] - in let record = record - ([ names ] @ package - @ [ ("source_dir", String (Path.Source.to_string t.dir)) - ; ("external_deps", list external_lib_dep_to_dyn t.external_deps) - ]) + [ ("names", (list string) t.names) + ; ( "package" + , option Package.Name.to_dyn (Option.map ~f:Package.name t.package) + ) + ; ("source_dir", String (Path.Source.to_string t.dir)) + ; ("external_deps", list external_lib_dep_to_dyn t.external_deps) + ] in Variant (Kind.to_string t.kind, [ record ]) end diff --git a/test/blackbox-tests/test-cases/external-lib-deps/exclude-internal-deps.t/run.t b/test/blackbox-tests/test-cases/external-lib-deps/exclude-internal-deps.t/run.t index 1574fe7bc78..bc82b209d9f 100644 --- a/test/blackbox-tests/test-cases/external-lib-deps/exclude-internal-deps.t/run.t +++ b/test/blackbox-tests/test-cases/external-lib-deps/exclude-internal-deps.t/run.t @@ -4,5 +4,13 @@ print only the external libraries by dir. $ dune describe external-lib-deps (default - ((. ((a required))) - (lib ((a required))))) + ((library + ((names (foo)) + (package ()) + (source_dir .) + (external_deps ((a required))))) + (library + ((names (inter_lib)) + (package ()) + (source_dir lib) + (external_deps ((a required))))))) diff --git a/test/blackbox-tests/test-cases/external-lib-deps/simple-pps.t/run.t b/test/blackbox-tests/test-cases/external-lib-deps/simple-pps.t/run.t index 5dbf6001550..c41d95832cb 100644 --- a/test/blackbox-tests/test-cases/external-lib-deps/simple-pps.t/run.t +++ b/test/blackbox-tests/test-cases/external-lib-deps/simple-pps.t/run.t @@ -2,13 +2,22 @@ Expected: To get all required and pps packages $ dune describe external-lib-deps (default - ((. - ((a________ required) - (b________ required) - (c________ required) - (d________ required) - (e________ required) - (f________ required) - (h________ required) - (i________ required) - (j________ required))))) + ((library + ((names (foo)) + (package ()) + (source_dir .) + (external_deps + ((a________ required) + (b________ required) + (c________ required) + (f________ required) + (e________ required) + (d________ required))))) + (executables + ((names (prog)) + (package ()) + (source_dir .) + (external_deps + ((h________ required) + (i________ required) + (j________ required))))))) diff --git a/test/blackbox-tests/test-cases/external-lib-deps/simple.t/run.t b/test/blackbox-tests/test-cases/external-lib-deps/simple.t/run.t index 06b446fe59b..9f0f4405e62 100644 --- a/test/blackbox-tests/test-cases/external-lib-deps/simple.t/run.t +++ b/test/blackbox-tests/test-cases/external-lib-deps/simple.t/run.t @@ -8,4 +8,9 @@ external library dependencies of a simple project > (libraries base doesnotexist.foo)) > EOF $ dune describe external-lib-deps - (default ((. ((base required) (doesnotexist.foo required))))) + (default + ((library + ((names (dummypkg)) + (package (dummypkg)) + (source_dir .) + (external_deps ((base required) (doesnotexist.foo required)))))))