Skip to content

Commit

Permalink
melange: repro of paths issues with include_subdirs (#9189)
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Chávarri <[email protected]>
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
  • Loading branch information
jchavarri authored Mar 19, 2024
1 parent fc75462 commit 62dadbe
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/blackbox-tests/test-cases/melange/library-include-subdirs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Test moving modules in a library with `(include_subdirs unqualified)`

$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using melange 0.1)
> EOF

$ cat > dune <<EOF
> (melange.emit
> (target output)
> (alias mel)
> (libraries foo)
> (emit_stdlib false)
> (preprocess (pps melange.ppx)))
> EOF

$ mkdir lib
$ cat > lib/dune <<EOF
> (include_subdirs unqualified)
> (library
> (name foo)
> (modes melange))
> EOF
$ cat > lib/foo.ml <<EOF
> let name = Bar.name
> EOF

$ mkdir lib/init
$ cat > lib/init/bar.ml <<EOF
> let name = "Zoe"
> EOF

$ dune build @mel

Melange shows the proper path to `bar.js`

$ cat _build/default/output/lib/foo.js | grep bar.js
let Foo__Bar = require("./init/bar.js");

$ mv lib/init lib/end

$ dune build @mel

The import in `foo.js` still shows the initial path to `bar.js`, but the file is not there anymore

$ cat _build/default/output/lib/foo.js | grep bar.js
let Foo__Bar = require("./init/bar.js");

$ test -f _build/default/output/lib/init/bar.js
[1]

$ test -f _build/default/output/lib/end/bar.js

After removal of the js artifact, the path in `bar.js` import is correct

$ rm _build/default/output/lib/foo.js

$ dune build @mel

$ cat _build/default/output/lib/foo.js | grep bar.js
let Foo__Bar = require("./end/bar.js");

0 comments on commit 62dadbe

Please sign in to comment.