Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter unavailable optional libs for utop #3612

Merged
merged 1 commit into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ next
- Fix compatibility with OCaml 4.12.0 when compiling empty archives; no .a file
is generated. (#3576, @dra27)

- `$ dune utop` no longer tries to load optional libraries that are unavailable
(#3612, fixes #3188, @anuragsoni)

2.6.1 (02/07/2020)
------------------

Expand Down
10 changes: 9 additions & 1 deletion src/dune/utop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ let libs_and_ppx_under_dir sctx ~db ~dir =
Implementations are selected using the default implementation
feature. *)
let not_impl = Option.is_none (Lib_info.implements info) in
if not_impl && Path.is_descendant ~of_:(Path.build dir) src_dir
let not_hidden =
match Lib_info.enabled info with
| Normal -> true
| Optional -> Result.is_ok (Lib.requires lib)
| Disabled_because_of_enabled_if -> false
in
if
not_impl && not_hidden
&& Path.is_descendant ~of_:(Path.build dir) src_dir
then
match Lib_info.kind info with
| Lib_kind.Ppx_rewriter _
Expand Down
9 changes: 9 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,14 @@
test-cases/github3180
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias github3188)
(deps (package dune) (source_tree test-cases/github3188) (alias test-deps))
(action
(chdir
test-cases/github3188
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias github3440)
(deps (package dune) (source_tree test-cases/github3440) (alias test-deps))
Expand Down Expand Up @@ -3121,6 +3129,7 @@
(alias github3043)
(alias github3046)
(alias github3180)
(alias github3188)
(alias github3440)
(alias github3490)
(alias github3530)
Expand Down
1 change: 1 addition & 0 deletions test/blackbox-tests/gen_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ let exclusions =
; make "mdx-stanza" ~external_deps:true
; make "toplevel-integration" ~external_deps:true
; make "bisect-ppx/main" ~external_deps:true
; make "github3188" ~external_deps:true
]
|> String_map.of_list_map_exn ~f:(fun (test : Test.t) -> (test.path, test))

Expand Down
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/github3188/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This test makes sure that the utop subcommand does not load optional libraries.

$ mkdir testutop
$ cat <<EOF > testutop/dune
> (library
> (name testutop)
> (optional)
> (libraries does_not_exist))
> EOF
$ echo 'let run () = print_endline "this will never run"' > testutop/testutop.ml
$ echo "(lang dune 2.0)" > dune-project
$ echo 'let () = print_endline "No Error"' > init_test.ml

$ dune utop testutop -- init_test.ml
No Error