From 9249351d2c04f2b6799a0ee52c0eed9a529beaaf Mon Sep 17 00:00:00 2001 From: Ali Caglayan Date: Mon, 11 May 2026 19:15:35 +0100 Subject: [PATCH] test: building module artifact targets under (include_subdirs qualified) Cram test reproducing an internal-error crash in Artifacts_obj.make when a stanza uses (include_subdirs qualified) and two qualified subdirectories define modules with the same leaf name. Covers all five module artifact pforms: %{cmi:...}, %{cmo:...}, %{cmx:...}, %{cmt:...}, %{cmti:...}. A normal build of the same stanza succeeds. When this is fixed, the test will need to be updated to capture the correct (non-crashing) output. Signed-off-by: Ali Caglayan --- .../module-artifact-targets.t | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 test/blackbox-tests/test-cases/include-qualified/module-artifact-targets.t diff --git a/test/blackbox-tests/test-cases/include-qualified/module-artifact-targets.t b/test/blackbox-tests/test-cases/include-qualified/module-artifact-targets.t new file mode 100644 index 00000000000..61d33942411 --- /dev/null +++ b/test/blackbox-tests/test-cases/include-qualified/module-artifact-targets.t @@ -0,0 +1,65 @@ +Building a module artifact target (%{cmi:...}, %{cmo:...}, %{cmx:...}, +%{cmt:...}, %{cmti:...}) should work when (include_subdirs qualified) is +used and two qualified subdirectories contain modules with the same leaf +name. + + $ make_dune_project 3.7 + + $ cat > dune < (include_subdirs qualified) + > (library (name main) (modes byte native)) + > EOF + $ cat > main.ml < let _ = (Sub_a.Group.x, Sub_b.Group.x) + > EOF + + $ mkdir sub_a sub_b + $ echo 'let x = "a"' > sub_a/group.ml + $ echo 'let x = "b"' > sub_b/group.ml + +A normal build succeeds: + + $ dune build @check + +Asking for any module artifact of a module in the stanza crashes with the +same internal error: + + $ dune build %{cmi:main} 2>&1 | head -5 + Internal error! Please report to https://github.com/ocaml/dune/issues, + providing the file _build/trace.csexp, if possible. This includes build + commands, message logs, and file paths. + Description: + ("Map.add_exn: key already exists", { key = "Group" }) + [1] + + $ dune build %{cmo:main} 2>&1 | head -5 + Internal error! Please report to https://github.com/ocaml/dune/issues, + providing the file _build/trace.csexp, if possible. This includes build + commands, message logs, and file paths. + Description: + ("Map.add_exn: key already exists", { key = "Group" }) + [1] + + $ dune build %{cmx:main} 2>&1 | head -5 + Internal error! Please report to https://github.com/ocaml/dune/issues, + providing the file _build/trace.csexp, if possible. This includes build + commands, message logs, and file paths. + Description: + ("Map.add_exn: key already exists", { key = "Group" }) + [1] + + $ dune build %{cmt:main} 2>&1 | head -5 + Internal error! Please report to https://github.com/ocaml/dune/issues, + providing the file _build/trace.csexp, if possible. This includes build + commands, message logs, and file paths. + Description: + ("Map.add_exn: key already exists", { key = "Group" }) + [1] + + $ dune build %{cmti:main} 2>&1 | head -5 + Internal error! Please report to https://github.com/ocaml/dune/issues, + providing the file _build/trace.csexp, if possible. This includes build + commands, message logs, and file paths. + Description: + ("Map.add_exn: key already exists", { key = "Group" }) + [1]