Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

*: add missing :with-test alcotest deps; broaden lint workspace check

Two changes squashed because they uncovered each other:

1. Sweep [(alcotest :with-test)] into 18 packages whose tests use
alcotest but didn't declare it in opam. Each verified by build +
runtest. Affected: ocaml-adm, ocaml-aem, ocaml-agent, ocaml-cdm,
ocaml-conpool, ocaml-coordinate, ocaml-csv, ocaml-demod, ocaml-dsp,
ocaml-flexacm, ocaml-globe, ocaml-kepler, ocaml-kvn, ocaml-rdm,
ocaml-respond, ocaml-spacedata, ocaml-stix, ocaml-vec3, osrelease.

2. [monopam lint] now treats every workspace-local library name as
workspace-internal, not just the ones with no [(public_name ...)].

Before, [local_private_libs] called [Dune.File.private_library_names]
which only returned [(library (name X))] stanzas WITHOUT a public
name. So a [(library (name cookie_jar) (public_name nox-cookie.jar))]
was treated as external -- a sibling [(test (libraries cookie_jar))]
triggered a [Missing_test] for a non-existent opam package
[cookie_jar].

Switch to [Dune.File.library_names] (every internal name) and rename
the helper to [local_library_names]. A workspace-local
[(libraries X)] now resolves to the workspace artifact regardless of
whether [X] also has a public_name; opam-package matching only
applies to truly-external library refs.

Cleared a swathe of false-positive missing-test reports for
subtrees that internally dot-name their sub-libraries (irmin's
irmin_admin/irmin_cbor/..., ocaml-cookie's cookie_jar, ocaml-claude-
skills's skills, etc.).

+12 -11
+12 -11
lib/lint.ml
··· 403 403 | exception Eio.Io _ -> []) 404 404 entries 405 405 406 - (** Names of [(library (name X))] stanzas in [subtree_path] that have no 407 - [(public_name ...)]. Sibling [(libraries X)] refs to such names link against 408 - a workspace-private archive, not an opam package, so they must not surface 409 - as a dep. Walks every [dune] file under the subtree via 410 - {!Dune.File.private_library_names}. *) 411 - let local_private_libs ~fs subtree_path = 406 + (** Internal [(library (name X))] names from every [dune] file under 407 + [subtree_path], regardless of whether [X] also has a [(public_name ...)]. 408 + Sibling [(libraries X)] refs that match one of these names resolve to a 409 + workspace-local archive, not an opam package, so they must not surface as a 410 + dep -- even when the resolved library is also published as e.g. 411 + [nox-foo.bar]. *) 412 + let local_library_names ~fs subtree_path = 412 413 dune_files_in ~fs subtree_path 413 414 |> List.concat_map (fun df -> 414 415 match load_file fs df with 415 416 | None -> [] 416 417 | Some content -> ( 417 418 match Dune.File.of_string content with 418 - | Ok t -> Dune.File.private_library_names t 419 + | Ok t -> Dune.File.library_names t 419 420 | Stdlib.Error _ -> [])) 420 421 |> String_set.of_list 421 422 ··· 425 426 stanzas; with [`Test] only test/tests stanzas. *) 426 427 let dune_needed_packages ?(scope = `Both) ~fs ~index subtree_path = 427 428 let dune_files = dune_files_in ~fs subtree_path in 428 - let private_libs = local_private_libs ~fs subtree_path in 429 + let local_libs = local_library_names ~fs subtree_path in 429 430 List.concat_map 430 431 (fun df -> 431 432 match load_file fs df with ··· 433 434 | Some content -> extract_used_libs ~scope (parse_sexps content)) 434 435 dune_files 435 436 |> List.filter_map (fun lib -> 436 - if is_builtin lib || String_set.mem lib private_libs then None 437 + if is_builtin lib || String_set.mem lib local_libs then None 437 438 else Some (lib_to_package index lib)) 438 439 |> String_set.of_list 439 440 ··· 517 518 | _ -> ()) 518 519 | _ -> ()) 519 520 stanzas; 520 - let local_private = local_private_libs ~fs subtree_path in 521 + let local_libs = local_library_names ~fs subtree_path in 521 522 let resolve lib = 522 523 match Hashtbl.find_opt internal_to_public lib with 523 524 | Some pub -> Some pub 524 525 | None -> 525 - if String_set.mem lib local_private then None 526 + if String_set.mem lib local_libs then None 526 527 else Some (lib_to_package index lib) 527 528 in 528 529 let tbl = Hashtbl.create 16 in