Skip to content

Commit 6cd8230

Browse files
authored
refactor(boot): fix path computation (#12455)
Signed-off-by: Rudi Grinberg <[email protected]>
1 parent ccd2b3a commit 6cd8230

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

boot/duneboot.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,13 +1350,18 @@ module Library = struct
13501350
let paths = Io.readdir dir in
13511351
List.partition_map paths ~f:(fun fn ->
13521352
let path = Filename.concat dir fn in
1353+
let is_dir = Sys.is_directory path in
13531354
let module_path =
1354-
match include_subdirs with
1355-
| Qualified -> fn :: module_path
1356-
| No | Unqualified -> module_path
1355+
match
1356+
match include_subdirs with
1357+
| No | Unqualified -> false
1358+
| Qualified -> is_dir
1359+
with
1360+
| true -> fn :: module_path
1361+
| false -> module_path
13571362
in
13581363
let arg = path, fn, module_path in
1359-
if Sys.is_directory path then Left arg else Right arg)
1364+
if is_dir then Left arg else Right arg)
13601365
in
13611366
let files =
13621367
List.filter_map files ~f:(fun (path, fn, module_path) ->

test/blackbox-tests/test-cases/boot/include-subdirs-qualified-unwrapped.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Currently doesn't work because it is not implemented.
3333
> EOF
3434
ocamlc -output-complete-exe -intf-suffix .dummy -g -o .duneboot.exe -I boot -I +unix unix.cma boot/types.ml boot/libs.ml boot/duneboot.ml
3535
./.duneboot.exe
36-
Fatal error: exception Failure("failed to find [B]")
36+
cd _boot && /OCAMLOPT -c -g -no-alias-deps -w -49-23-53 -alert -unstable main.ml
37+
File "main.ml", line 3, characters 5-6:
38+
3 | open C
39+
^
40+
Error: Unbound module C
3741
[2]
3842

test/blackbox-tests/test-cases/boot/include-subdirs-qualified-wrapped.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Currently doesn't work because it is not implemented.
3333
> EOF
3434
ocamlc -output-complete-exe -intf-suffix .dummy -g -o .duneboot.exe -I boot -I +unix unix.cma boot/types.ml boot/libs.ml boot/duneboot.ml
3535
./.duneboot.exe
36-
Fatal error: exception Failure("failed to find [B;A]")
36+
cd _boot && /OCAMLOPT -c -g -no-alias-deps -w -49-23-53 -alert -unstable main.ml
37+
File "main.ml", line 3, characters 5-6:
38+
3 | open B
39+
^
40+
Error: Unbound module B
3741
[2]
3842

0 commit comments

Comments
 (0)