diff --git a/lib/lint.ml b/lib/lint.ml index 067cb0e..bb9de21 100644 --- a/lib/lint.ml +++ b/lib/lint.ml @@ -231,7 +231,7 @@ module Checks = struct | OpamFormula.Atom (pkg, constr) -> if is_dune pkg then let v = get_lower_bound constr in - Some (Option.default "1.0" v) + Some (Option.default "" v) else None | Empty -> None | Block x -> aux x @@ -249,10 +249,11 @@ module Checks = struct match (dune_constraint, dune_version) with | _, Error msg -> [ (pkg, FailedToDownload msg) ] | None, Ok None -> [] + | Some "", _ -> [ (pkg, DuneLowerBoundMissing) ] | Some _, Ok None -> [ (pkg, DuneProjectMissing) ] | None, Ok (Some _) -> if is_dune (OpamPackage.name pkg) then [] - else [ (pkg, DuneConstraintMissing) ] + else [ (pkg, DuneDependencyMissing) ] | Some dep, Ok (Some ver) -> if OpamVersionCompare.compare dep ver >= 0 then [] else [ (pkg, BadDuneConstraint (dep, ver)) ] diff --git a/lib/lint_error.ml b/lib/lint_error.ml index 36e8f03..6122672 100644 --- a/lib/lint_error.ml +++ b/lib/lint_error.ml @@ -15,7 +15,8 @@ type error = | UnmatchedVersion of OpamPackage.Version.t | DubiousDuneSubst | DuneProjectMissing - | DuneConstraintMissing + | DuneDependencyMissing + | DuneLowerBoundMissing | DuneIsBuild | BadDuneConstraint of string * string | UnexpectedFile of string @@ -99,11 +100,16 @@ let msg_of_error (package, (err : error)) = "Warning in %s: The package seems to use dune but the dune-project \ file is missing." pkg - | DuneConstraintMissing -> + | DuneDependencyMissing -> Printf.sprintf "Warning in %s: The package has a dune-project file but no explicit \ dependency on dune was found." pkg + | DuneLowerBoundMissing -> + Printf.sprintf + "Warning in %s: The package has a dune dependency without a lower \ + bound." + pkg | BadDuneConstraint (dep, ver) -> Printf.sprintf "Error in %s: Your dune-project file indicates that this package \ diff --git a/test/lint.t b/test/lint.t index 9870736..6402f4f 100644 --- a/test/lint.t +++ b/test/lint.t @@ -24,6 +24,9 @@ Setup repo for incorrect b package tests $ git apply "patches/b-incorrect-opam.patch" $ git add packages/ $ echo "(lang dune 3.16)" > dune-project + $ sh "scripts/setup_sources.sh" b 0.0.2 dune-project + Created tarball b.0.0.2.tgz + Updated checksum for b.0.0.2.tgz in b.0.0.2's opam file $ sh "scripts/setup_sources.sh" b 0.0.3 dune-project Created tarball b.0.0.3.tgz Updated checksum for b.0.0.3.tgz in b.0.0.3's opam file @@ -63,9 +66,8 @@ Test the following: Linting opam-repository at $TESTCASE_ROOT/. ... 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). 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. - Error in b.0.0.2: Failed to download the archive. Details: $TESTCASE_ROOT/b.0.0.2.tgz + Warning in b.0.0.2: The package has a dune dependency without a lower bound. Error in b.0.0.2: error 3: File format error in 'unknown-field' at line 11, column 0: Invalid field unknown-field - Error in b.0.0.2: error 60: Upstream check failed: "Source not found: $TESTCASE_ROOT/b.0.0.2.tgz" [1] $ opam-ci-check lint -r . -c b.0.0.3 Linting opam-repository at $TESTCASE_ROOT/. ...