From 271f5fd16ac56b54ef444435d6fd774699ada1ca Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Thu, 27 Apr 2023 13:20:27 -0700 Subject: [PATCH] test(melange): incorrect path when public lib depends on private lib Signed-off-by: Antonio Nuno Monteiro --- .../test-cases/melange/private-lib-dep.t | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/blackbox-tests/test-cases/melange/private-lib-dep.t diff --git a/test/blackbox-tests/test-cases/melange/private-lib-dep.t b/test/blackbox-tests/test-cases/melange/private-lib-dep.t new file mode 100644 index 00000000000..18a9e0a5e17 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/private-lib-dep.t @@ -0,0 +1,57 @@ +Melange public library depends on private library + + $ cat > dune-project < (lang dune 3.8) + > (package (name foo)) + > (using melange 0.1) + > EOF + + $ mkdir -p priv + $ cat > priv/dune < (library + > (name priv) + > (package foo) + > (modes melange)) + > EOF + $ cat > priv/priv.ml < let x = "private" + > EOF + + $ mkdir -p lib + $ cat > lib/dune < (library + > (public_name foo) + > (modes melange) + > (libraries priv)) + > EOF + $ cat > lib/foo.ml < let x = "public lib uses " ^ Priv.x + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (libraries foo) + > (emit_stdlib false)) + > EOF + + $ cat > entry.ml < let () = Js.log Foo.x + > EOF + + $ dune build @melange + + $ node _build/default/output/entry.js 2>&1 | grep 'Cannot find module' + Error: Cannot find module 'priv/priv.js' + + $ cat _build/default/output/node_modules/foo/foo.js + // Generated by Melange + 'use strict'; + + var Priv = require("priv/priv.js"); + + var x = "public lib uses " + Priv.x; + + exports.x = x; + /* No side effect */ +