Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 8af2b49

Browse files
committed
Differentiate between missing dune dependency vs lower bound
Previously, we incorrectly showed a missing dune dependency error, when a version lower bound constraint was missing. This commit improves the error messages to differentiate between missing lower bound constraint vs missing the dune dependency entirely.
1 parent 4c2ff93 commit 8af2b49

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

lib/lint.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ module Checks = struct
231231
| OpamFormula.Atom (pkg, constr) ->
232232
if is_dune pkg then
233233
let v = get_lower_bound constr in
234-
Some (Option.default "1.0" v)
234+
Some (Option.default "" v)
235235
else None
236236
| Empty -> None
237237
| Block x -> aux x
@@ -249,10 +249,11 @@ module Checks = struct
249249
match (dune_constraint, dune_version) with
250250
| _, Error msg -> [ (pkg, FailedToDownload msg) ]
251251
| None, Ok None -> []
252+
| Some "", _ -> [ (pkg, DuneLowerBoundMissing) ]
252253
| Some _, Ok None -> [ (pkg, DuneProjectMissing) ]
253254
| None, Ok (Some _) ->
254255
if is_dune (OpamPackage.name pkg) then []
255-
else [ (pkg, DuneConstraintMissing) ]
256+
else [ (pkg, DuneDependencyMissing) ]
256257
| Some dep, Ok (Some ver) ->
257258
if OpamVersionCompare.compare dep ver >= 0 then []
258259
else [ (pkg, BadDuneConstraint (dep, ver)) ]

lib/lint_error.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ type error =
1515
| UnmatchedVersion of OpamPackage.Version.t
1616
| DubiousDuneSubst
1717
| DuneProjectMissing
18-
| DuneConstraintMissing
18+
| DuneDependencyMissing
19+
| DuneLowerBoundMissing
1920
| DuneIsBuild
2021
| BadDuneConstraint of string * string
2122
| UnexpectedFile of string
@@ -99,11 +100,16 @@ let msg_of_error (package, (err : error)) =
99100
"Warning in %s: The package seems to use dune but the dune-project \
100101
file is missing."
101102
pkg
102-
| DuneConstraintMissing ->
103+
| DuneDependencyMissing ->
103104
Printf.sprintf
104105
"Warning in %s: The package has a dune-project file but no explicit \
105106
dependency on dune was found."
106107
pkg
108+
| DuneLowerBoundMissing ->
109+
Printf.sprintf
110+
"Warning in %s: The package has a dune dependency without a lower \
111+
bound."
112+
pkg
107113
| BadDuneConstraint (dep, ver) ->
108114
Printf.sprintf
109115
"Error in %s: Your dune-project file indicates that this package \

test/lint.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Setup repo for incorrect b package tests
2424
$ git apply "patches/b-incorrect-opam.patch"
2525
$ git add packages/
2626
$ echo "(lang dune 3.16)" > dune-project
27+
$ sh "scripts/setup_sources.sh" b 0.0.2 dune-project
28+
Created tarball b.0.0.2.tgz
29+
Updated checksum for b.0.0.2.tgz in b.0.0.2's opam file
2730
$ sh "scripts/setup_sources.sh" b 0.0.3 dune-project
2831
Created tarball b.0.0.3.tgz
2932
Updated checksum for b.0.0.3.tgz in b.0.0.3's opam file
@@ -63,9 +66,8 @@ Test the following:
6366
Linting opam-repository at $TESTCASE_ROOT/. ...
6467
Warning in b.0.0.2: Dubious use of 'dune subst'. 'dune subst' should always only be called with {dev} (i.e. ["dune" "subst"] {dev}) If your opam file has been autogenerated by dune, you need to upgrade your dune-project to at least (lang dune 2.7).
6568
Warning in b.0.0.2: The package tagged dune as a build dependency. Due to a bug in dune (https://github.com/ocaml/dune/issues/2147) this should never be the case. Please remove the {build} tag from its filter.
66-
Error in b.0.0.2: Failed to download the archive. Details: $TESTCASE_ROOT/b.0.0.2.tgz
69+
Warning in b.0.0.2: The package has a dune dependency without a lower bound.
6770
Error in b.0.0.2: error 3: File format error in 'unknown-field' at line 11, column 0: Invalid field unknown-field
68-
Error in b.0.0.2: error 60: Upstream check failed: "Source not found: $TESTCASE_ROOT/b.0.0.2.tgz"
6971
[1]
7072
$ opam-ci-check lint -r . -c b.0.0.3
7173
Linting opam-repository at $TESTCASE_ROOT/. ...

0 commit comments

Comments
 (0)