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

Better "since" error messages #3414

Merged
merged 3 commits into from
Apr 22, 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
2 changes: 1 addition & 1 deletion src/dune/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let relative_file =
let library_variants =
let syntax =
Dune_lang.Syntax.create ~name:"library_variants"
~desc:"the experimental library variants feature."
~desc:"the experimental library variants feature"
[ ((0, 1), `Since (1, 9)); ((0, 2), `Since (1, 11)) ]
in
Dune_project.Extension.register_simple ~experimental:true syntax
Expand Down
11 changes: 9 additions & 2 deletions src/dune_lang/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,17 @@ type t =

module Error_msg = struct
let since t ver ~what =
let lang_or_using =
if t.name = "dune" then
"lang"
else
"using"
in
Printf.sprintf
"%s is only available since version %s of %s. Please update your \
dune-project file to have (lang %s)."
what (Version.to_string ver) t.desc (Version.to_string ver)
dune-project file to have (%s %s %s)."
what (Version.to_string ver) t.desc lang_or_using t.name
(Version.to_string ver)
end

module Error = struct
Expand Down
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,14 @@
test-cases/github3180
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

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

(rule
(alias github534)
(deps (package dune) (source_tree test-cases/github534))
Expand Down Expand Up @@ -2567,6 +2575,7 @@
(alias github2848)
(alias github3046)
(alias github3180)
(alias github3412)
(alias github534)
(alias github568)
(alias github597)
Expand Down Expand Up @@ -2852,6 +2861,7 @@
(alias github2848)
(alias github3046)
(alias github3180)
(alias github3412)
(alias github534)
(alias github568)
(alias github597)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ version that introduced this feature:
^^^^^^^^^^^^
Error: to_copy/* is not a sub-directory of src. This is only available since
version 1.3 of the dune language. Please update your dune-project file to
have (lang 1.3).
have (lang dune 1.3).
[1]
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/dune-project-meta/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Not supported before 2.1:
6 | (depends (conf-libX11 (<> :os win32))))
^^^^^^^^^^^^^^
Error: Passing two arguments to <> is only available since version 2.1 of the
dune language. Please update your dune-project file to have (lang 2.1).
dune language. Please update your dune-project file to have (lang dune 2.1).
[1]

Supported since 2.1:
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/foreign-library/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Testsuite for the (foreign_library ...) stanza.
2 | (language c)
3 | (names add))
Error: 'foreign_library' is only available since version 2.0 of the dune
language. Please update your dune-project file to have (lang 2.0).
language. Please update your dune-project file to have (lang dune 2.0).
[1]

----------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/github3412/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name toto)
(variant x))
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/github3412/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 2.5)
8 changes: 8 additions & 0 deletions test/blackbox-tests/test-cases/github3412/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$ dune build
File "dune", line 3, characters 2-13:
3 | (variant x))
^^^^^^^^^^^
Error: 'variant' is only available since version 0.1 of the experimental
library variants feature. Please update your dune-project file to have (using
library_variants 0.1).
[1]
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/lib/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TODO: Fix %{libexec} and %{libexec-private} variables and test them.
3 | (action (echo "%{lib-private:private_lib:a.ml}")))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: %{lib-private:..} is only available since version 2.1 of the dune
language. Please update your dune-project file to have (lang 2.1).
language. Please update your dune-project file to have (lang dune 2.1).
[1]

----------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/mdx-stanza/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ It also requires dune lang 2.4 or higher
1 | (mdx)
^^^^^
Error: 'mdx' is only available since version 2.4 of the dune language. Please
update your dune-project file to have (lang 2.4).
update your dune-project file to have (lang dune 2.4).
[1]

You can use the mdx stanza to check your documentation in markdown and mli files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ If there is an (action) field defined in a test stanza and dune-project sets
3 | (action (run %{test}))
^^^^^^^^^^^^^^^^^^^^^^
Warning: 'action' is only available since version 1.2 of the dune language.
Please update your dune-project file to have (lang 1.2).
Please update your dune-project file to have (lang dune 1.2).
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/vendor/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The vendored_dirs stanza is available from version 1.11 of the dune language
1 | (vendored_dirs *)
^^^^^^^^^^^^^^^^^
Error: 'vendored_dirs' is only available since version 1.11 of the dune
language. Please update your dune-project file to have (lang 1.11).
language. Please update your dune-project file to have (lang dune 1.11).
[1]

The same directory cannot be marked as both vendored and data-only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
10 | (run ./exit.exe 1)))))
Error: nesting modifiers under 'with-accepted-exit-codes' is only available
since version 2.2 of the dune language. Please update your dune-project file
to have (lang 2.2).
to have (lang dune 2.2).
[1]