diff --git a/bin/pkg/lock.ml b/bin/pkg/lock.ml index 42bcf23babf..63005dfc985 100644 --- a/bin/pkg/lock.ml +++ b/bin/pkg/lock.ml @@ -35,8 +35,6 @@ let check_for_dup_lock_dir_paths ts = let solve per_context - ~opam_repository_path - ~opam_repository_url ~update_opam_repositories ~solver_env_from_current_system ~experimental_translate_opam_filters @@ -64,14 +62,7 @@ let solve let solver_env = solver_env ~solver_env_from_context ~solver_env_from_current_system in - let* repos = - get_repos - repos - ~opam_repository_path - ~opam_repository_url - ~repositories - ~update_opam_repositories - in + let* repos = get_repos repos ~repositories ~update_opam_repositories in let overlay = Console.Status_line.add_overlay (Constant (Pp.text "Solving for Build Plan")) in @@ -130,8 +121,6 @@ let lock ~all_contexts ~dont_poll_system_solver_variables ~version_preference - ~opam_repository_path - ~opam_repository_url ~update_opam_repositories ~experimental_translate_opam_filters = @@ -151,8 +140,6 @@ let lock in solve per_context - ~opam_repository_path - ~opam_repository_url ~update_opam_repositories ~solver_env_from_current_system ~experimental_translate_opam_filters @@ -160,8 +147,6 @@ let lock let term = let+ builder = Common.Builder.term - and+ opam_repository_path = Opam_repository_path.term - and+ opam_repository_url = Opam_repository_url.term and+ context_name = context_term ~doc: @@ -213,8 +198,6 @@ let term = ~all_contexts ~dont_poll_system_solver_variables ~version_preference - ~opam_repository_path - ~opam_repository_url ~update_opam_repositories:(not skip_update) ~experimental_translate_opam_filters) ;; diff --git a/bin/pkg/outdated.ml b/bin/pkg/outdated.ml index c32938444a3..fbf533fe8fe 100644 --- a/bin/pkg/outdated.ml +++ b/bin/pkg/outdated.ml @@ -3,14 +3,7 @@ open Pkg_common module Lock_dir = Dune_pkg.Lock_dir module Opam_repo = Dune_pkg.Opam_repo -let find_outdated_packages - ~context_name_arg - ~all_contexts_arg - ~opam_repository_path - ~opam_repository_url - ~transitive - () - = +let find_outdated_packages ~context_name_arg ~all_contexts_arg ~transitive () = let open Fiber.O in let+ pps, not_founds = Per_context.choose ~context_name_arg ~all_contexts_arg ~version_preference_arg:None @@ -27,13 +20,7 @@ let find_outdated_packages } -> (* updating makes sense when checking for outdated packages *) - let* repos = - get_repos - repos - ~opam_repository_path - ~opam_repository_url - ~repositories - ~update_opam_repositories:true + let* repos = get_repos repos ~repositories ~update_opam_repositories:true and+ local_packages = find_local_packages in let lock_dir = Lock_dir.read_disk lock_dir_path in let+ results = @@ -89,8 +76,6 @@ let term = value & flag & info [ "all-contexts" ] ~doc:"Check for outdated packages in all contexts") - and+ opam_repository_path = Opam_repository_path.term - and+ opam_repository_url = Opam_repository_url.term and+ transitive = Arg.( value @@ -102,12 +87,7 @@ let term = let builder = Common.Builder.forbid_builds builder in let common, config = Common.init builder in Scheduler.go ~common ~config - @@ find_outdated_packages - ~context_name_arg - ~all_contexts_arg - ~opam_repository_path - ~opam_repository_url - ~transitive + @@ find_outdated_packages ~context_name_arg ~all_contexts_arg ~transitive ;; let info = diff --git a/bin/pkg/pkg_common.ml b/bin/pkg/pkg_common.ml index 36c3fbdf8ed..058f9fa90c5 100644 --- a/bin/pkg/pkg_common.ml +++ b/bin/pkg/pkg_common.ml @@ -143,49 +143,27 @@ let location_of_opam_url url = ] ;; -let get_repos - repos - ~opam_repository_path - ~opam_repository_url - ~repositories - ~update_opam_repositories - = +let get_repos repos ~repositories ~update_opam_repositories = let module Repository_id = Dune_pkg.Repository_id in let module Opam_repo = Dune_pkg.Opam_repo in - let open Fiber.O in - match opam_repository_path, opam_repository_url with - | Some _, Some _ -> - (* in theory you can set both, but how to prioritize them? *) - User_error.raise [ Pp.text "Can't specify both path and URL to an opam-repository" ] - | Some path, None -> - let repo_id = Repository_id.of_path path in - Fiber.return @@ [ Opam_repo.of_opam_repo_dir_path ~source:None ~repo_id path ] - | None, Some (url : OpamUrl.t) -> - let+ opam_repo = - Opam_repo.of_git_repo - ~repo_id:None - ~update:update_opam_repositories - ~source:url.path - in - [ opam_repo ] - | None, None -> - repositories - |> Fiber.parallel_map ~f:(fun name -> - match Dune_pkg.Pkg_workspace.Repository.Name.Map.find repos name with - | None -> - (* TODO: have loc for this failure? *) - User_error.raise - [ Pp.textf "Repository '%s' is not a known repository" - @@ Dune_pkg.Pkg_workspace.Repository.Name.to_string name - ] - | Some repo -> - let opam_url = Dune_pkg.Pkg_workspace.Repository.opam_url repo in - (match location_of_opam_url opam_url with - | `Git source -> - Opam_repo.of_git_repo ~repo_id:None ~update:update_opam_repositories ~source - | `Path path -> - let repo_id = Repository_id.of_path path in - Fiber.return @@ Opam_repo.of_opam_repo_dir_path ~source:None ~repo_id path)) + let module Repository = Dune_pkg.Pkg_workspace.Repository in + repositories + |> Fiber.parallel_map ~f:(fun name -> + match Repository.Name.Map.find repos name with + | None -> + (* TODO: have loc for this failure? *) + User_error.raise + [ Pp.textf "Repository '%s' is not a known repository" + @@ Repository.Name.to_string name + ] + | Some repo -> + let opam_url = Dune_pkg.Pkg_workspace.Repository.opam_url repo in + (match location_of_opam_url opam_url with + | `Git source -> + Opam_repo.of_git_repo ~repo_id:None ~update:update_opam_repositories ~source + | `Path path -> + let repo_id = Repository_id.of_path path in + Fiber.return @@ Opam_repo.of_opam_repo_dir_path ~source:None ~repo_id path)) ;; let find_local_packages = @@ -197,52 +175,6 @@ let find_local_packages = Dune_project.packages project |> Package.Name.Map.map ~f:Package.to_local_package ;; -module Opam_repository_path = struct - let term = - let dune_path = - let parser s = - s - |> Path.External.of_filename_relative_to_initial_cwd - |> Path.external_ - |> Result.ok - in - let printer pf p = Pp.to_fmt pf (Path.pp p) in - Arg.conv (parser, printer) - in - Arg.( - value - & opt (some dune_path) None - & info - [ "opam-repository-path" ] - ~docv:"PATH" - ~doc: - "Path to a local opam repository. This should be a directory containing a \ - valid opam repository such as the one at \ - https://github.com/ocaml/opam-repository.") - ;; -end - -module Opam_repository_url = struct - let term = - let parser s = - match OpamUrl.parse_opt s with - | Some url -> Ok url - | None -> Error (`Msg "URL can't be parsed") - in - let printer pf u = Pp.to_fmt pf (Pp.text (OpamUrl.to_string u)) in - let opam_url = Arg.conv (parser, printer) in - Arg.( - value - & opt (some opam_url) None - & info - [ "opam-repository-url" ] - ~docv:"URL" - ~doc: - "URL of opam repository to download. Can be either a git repository or a \ - link to the tarball of a repository.") - ;; -end - let pp_packages packages = let module Package_version = Dune_pkg.Package_version in Pp.enumerate diff --git a/bin/pkg/pkg_common.mli b/bin/pkg/pkg_common.mli index f4ae4957986..f81b7296684 100644 --- a/bin/pkg/pkg_common.mli +++ b/bin/pkg/pkg_common.mli @@ -38,22 +38,12 @@ end val get_repos : Dune_pkg.Pkg_workspace.Repository.t Dune_pkg.Pkg_workspace.Repository.Name.Map.t - -> opam_repository_path:Path.t option - -> opam_repository_url:OpamUrl.t option -> repositories:Dune_pkg.Pkg_workspace.Repository.Name.t list -> update_opam_repositories:bool -> Dune_pkg.Opam_repo.t list Fiber.t val find_local_packages : Dune_pkg.Local_package.t Package_name.Map.t Fiber.t -module Opam_repository_path : sig - val term : Path.t option Term.t -end - -module Opam_repository_url : sig - val term : OpamUrl.t option Term.t -end - (** [pp_packages lock_dir] returns a list of pretty-printed packages occuring in [lock_dir]. *) val pp_packages : Dune_pkg.Lock_dir.Pkg.t list -> 'a Pp.t diff --git a/test/blackbox-tests/test-cases/pkg/additional-constraints.t b/test/blackbox-tests/test-cases/pkg/additional-constraints.t index 4706a334124..b34f1af4f44 100644 --- a/test/blackbox-tests/test-cases/pkg/additional-constraints.t +++ b/test/blackbox-tests/test-cases/pkg/additional-constraints.t @@ -5,7 +5,11 @@ It's possible to include additional packages or constraints in workspace files: $ cat >dune-workspace < (lang dune 3.11) > (lock_dir - > (constraints doesnotexist foo (bar (= 1.0.0)))) + > (constraints doesnotexist foo (bar (= 1.0.0))) + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF $ mkrepo diff --git a/test/blackbox-tests/test-cases/pkg/describe-pkg-lock.t b/test/blackbox-tests/test-cases/pkg/describe-pkg-lock.t index 932fdc49156..099bb321927 100644 --- a/test/blackbox-tests/test-cases/pkg/describe-pkg-lock.t +++ b/test/blackbox-tests/test-cases/pkg/describe-pkg-lock.t @@ -20,6 +20,14 @@ First we setup a repo. > (default > (name "foo") > (lock_dir foo.lock))) + > (lock_dir + > (repositories mock)) + > (lock_dir + > (path foo.lock) + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Here is the output of solving for multiple contexts: diff --git a/test/blackbox-tests/test-cases/pkg/detect-duplicate-lock-dir-paths.t b/test/blackbox-tests/test-cases/pkg/detect-duplicate-lock-dir-paths.t index 63888b750a6..97131b0481f 100644 --- a/test/blackbox-tests/test-cases/pkg/detect-duplicate-lock-dir-paths.t +++ b/test/blackbox-tests/test-cases/pkg/detect-duplicate-lock-dir-paths.t @@ -12,21 +12,26 @@ Define several build contexts that all use the default lockdir > (context > (default > (name custom-context-with-default-lock-dir))) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Check that we can still generate lockdirs for individual contexts: - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: (no dependencies to lock) - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=default + $ dune pkg lock --context=default Solution for dune.lock: (no dependencies to lock) - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=custom-context-with-default-lock-dir + $ dune pkg lock --context=custom-context-with-default-lock-dir Solution for dune.lock: (no dependencies to lock) It's an error to use --all-contexts when there are multiple contexts with the same lockdir: - $ dune pkg lock --opam-repository-path=mock-opam-repository --all-contexts + $ dune pkg lock --all-contexts File "dune-workspace", line 5, characters 1-56: 5 | (default 6 | (name custom-context-with-default-lock-dir))) @@ -48,18 +53,24 @@ Define several build contexts that all use the same custom lockdir: > (default > (name a) > (lock_dir foo.lock))) + > (lock_dir + > (path foo.lock) + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Check that we can still generate lockdirs for individual contexts: - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=a + $ dune pkg lock --context=a Solution for foo.lock: (no dependencies to lock) - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=b + $ dune pkg lock --context=b Solution for foo.lock: (no dependencies to lock) It's an error to use --all-contexts when there are multiple contexts with the same lockdir: - $ dune pkg lock --opam-repository-path=mock-opam-repository --all-contexts + $ dune pkg lock --all-contexts File "dune-workspace", line 7, characters 1-43: 7 | (default 8 | (name a) diff --git a/test/blackbox-tests/test-cases/pkg/env-conditional-dependencies.t b/test/blackbox-tests/test-cases/pkg/env-conditional-dependencies.t index b9ad2f9cd25..98844cc5f12 100644 --- a/test/blackbox-tests/test-cases/pkg/env-conditional-dependencies.t +++ b/test/blackbox-tests/test-cases/pkg/env-conditional-dependencies.t @@ -31,10 +31,12 @@ Create a workspace config that defines separate build contexts for macos and lin > (lang dune 3.8) > (lock_dir > (path dune.linux.lock) + > (repositories mock) > (solver_env > (os linux))) > (lock_dir > (path dune.macos.lock) + > (repositories mock) > (solver_env > (os macos))) > (context @@ -45,10 +47,13 @@ Create a workspace config that defines separate build contexts for macos and lin > (default > (name macos) > (lock_dir dune.macos.lock))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Now the os-specific dependencies are included on their respective systems. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository --all-contexts + $ dune pkg lock --dont-poll-system-solver-variables --all-contexts Solution for dune.macos.lock: - foo.0.0.1 - foo-macos.0.0.1 diff --git a/test/blackbox-tests/test-cases/pkg/helpers.sh b/test/blackbox-tests/test-cases/pkg/helpers.sh index c1b0e5d313e..4a6208c92ce 100644 --- a/test/blackbox-tests/test-cases/pkg/helpers.sh +++ b/test/blackbox-tests/test-cases/pkg/helpers.sh @@ -39,16 +39,53 @@ mkpkg() { cat >>$mock_packages/$name/$name.$version/opam } +add_mock_repo_if_needed() { + if [ ! -e dune-workspace ] + then + cat >dune-workspace < /dev/null dune-workspace + then + # add the repo definition + cat >>dune-workspace <>dune-workspace <dune-project - dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository $@ + add_mock_repo_if_needed + dune pkg lock --dont-poll-system-solver-variables $@ } solve_project_translate_opam_filters() { cat >dune-project + add_mock_repo_if_needed dune pkg lock \ --dont-poll-system-solver-variables \ - --opam-repository-path=mock-opam-repository \ --experimental-translate-opam-filters } diff --git a/test/blackbox-tests/test-cases/pkg/invalid-opam-repo-errors.t/run.t b/test/blackbox-tests/test-cases/pkg/invalid-opam-repo-errors.t/run.t index 4dd90ca53ca..197426b489a 100644 --- a/test/blackbox-tests/test-cases/pkg/invalid-opam-repo-errors.t/run.t +++ b/test/blackbox-tests/test-cases/pkg/invalid-opam-repo-errors.t/run.t @@ -5,21 +5,45 @@ Test the error cases for invalid opam repositories > (package > (name lockfile_generation_test)) > EOF + > cat >dune-workspace < (lang dune 3.8) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/directory-that-does-not-exist")) + > EOF - $ dune pkg lock --opam-repository-path=directory-that-does-not-exist + $ dune pkg lock Error: $TESTCASE_ROOT/directory-that-does-not-exist does not exist [1] $ touch empty - $ dune pkg lock --opam-repository-path=empty + $ cat >dune-workspace < (lang dune 3.8) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/empty")) + > EOF + $ dune pkg lock Error: $TESTCASE_ROOT/empty is not a directory [1] - $ dune pkg lock --opam-repository-path=no-packages-dir + $ cat >dune-workspace < (lang dune 3.8) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/no-packages-dir")) + > EOF + $ dune pkg lock Error: $TESTCASE_ROOT/no-packages-dir doesn't look like a path to an opam repository as it lacks a subdirectory diff --git a/test/blackbox-tests/test-cases/pkg/invalid-version.t b/test/blackbox-tests/test-cases/pkg/invalid-version.t index 579bfd2bc0f..b814f81f5ad 100644 --- a/test/blackbox-tests/test-cases/pkg/invalid-version.t +++ b/test/blackbox-tests/test-cases/pkg/invalid-version.t @@ -3,12 +3,23 @@ an uncaught exception. It is very likely that users will type foo.1.2.3 for a pa version due to the convention in opam. In this case we could also give a hint how to write it in a dune-project file. + $ . ./helpers.sh + $ mkrepo + $ mkpkg foo 1.2.3 $ cat > dune-project < (lang dune 3.13) > (package > (name invalid) > (depends foo.1.2.3)) > EOF + $ cat >dune-workspace < (lang dune 3.13) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) + > EOF $ dune pkg lock 2>&1 | head -n1 Error: exception Failure("Invalid character in package name \"foo.1.2.3\"") diff --git a/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t b/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t index 2fe827d475f..7fb1ce023b3 100644 --- a/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t +++ b/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t @@ -1,5 +1,14 @@ Create a lock directory that didn't originally exist - $ dune pkg lock --opam-repository-path=mock-opam-repository + + $ cat >dune-workspace < (lang dune 3.10) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) + > EOF + $ dune pkg lock Solution for dune.lock: (no dependencies to lock) $ cat dune.lock/lock.dune @@ -10,7 +19,7 @@ Create a lock directory that didn't originally exist (used)) Re-create a lock directory in the newly created lock dir - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: (no dependencies to lock) $ cat dune.lock/lock.dune @@ -23,7 +32,7 @@ Re-create a lock directory in the newly created lock dir Attempt to create a lock directory inside an existing directory without a lock.dune file $ rm -rf dune.lock $ cp -r dir-without-metadata dune.lock - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Error: Refusing to regenerate lock directory dune.lock Specified lock dir lacks metadata file (lock.dune) [1] @@ -31,7 +40,7 @@ Attempt to create a lock directory inside an existing directory without a lock.d Attempt to create a lock directory inside an existing directory with an invalid lock.dune file $ rm -rf dune.lock $ cp -r dir-with-invalid-metadata dune.lock - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Error: Refusing to regenerate lock directory dune.lock Unable to parse lock directory metadata file (dune.lock/lock.dune): File "dune.lock/lock.dune", line 1, characters 0-12: @@ -42,7 +51,7 @@ Attempt to create a lock directory inside an existing directory with an invalid Attempt to create a lock directory with the same name as an existing regular file $ rm -rf dune.lock $ touch dune.lock - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Error: Refusing to regenerate lock directory dune.lock Specified lock dir path is not a directory [1] diff --git a/test/blackbox-tests/test-cases/pkg/lock-per-context.t/run.t b/test/blackbox-tests/test-cases/pkg/lock-per-context.t/run.t index ae4d4cc435d..9a17843784f 100644 --- a/test/blackbox-tests/test-cases/pkg/lock-per-context.t/run.t +++ b/test/blackbox-tests/test-cases/pkg/lock-per-context.t/run.t @@ -3,10 +3,15 @@ Create a workspace with multiple contexts, each specifying a lockdir name. > (lang dune 3.8) > (lock_dir > (path foo.lock) + > (repositories mock) > (version_preference newest)) ; this is the default > (lock_dir > (path prefers_oldest.lock) + > (repositories mock) > (version_preference oldest)) + > (lock_dir + > (path bar.lock) + > (repositories mock)) > (context > (default > (lock_dir foo.lock))) @@ -22,6 +27,9 @@ Create a workspace with multiple contexts, each specifying a lockdir name. > (opam > (name bar) > (switch default))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Generate a `dune-project` file listing some dependencies. @@ -36,22 +44,22 @@ Generate a `dune-project` file listing some dependencies. > EOF Test that we get an error when --context and --all-contexts are passed at the same time. - $ dune pkg lock --opam-repository-path=mock-opam-repository --all-contexts --context=foo + $ dune pkg lock --all-contexts --context=foo Error: --context and --all-contexts are mutually exclusive [1] Test that we get an error if a non-existant context is specified. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=baz + $ dune pkg lock --context=baz Error: Unknown build context: baz [1] Test that we get an error if an opam context is specified. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=bar + $ dune pkg lock --context=bar Error: Unexpected opam build context: bar [1] Generate the lockdir for the default context. - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for foo.lock: - bar.0.5.0 - baz.0.1.0 @@ -67,7 +75,7 @@ Only foo.lock (the default context's lockdir) was generated. $ rm -rf *.lock Generate the lockdir with the default context explicitly specified. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=default + $ dune pkg lock --context=default Solution for foo.lock: - bar.0.5.0 - baz.0.1.0 @@ -83,7 +91,7 @@ Again, only foo.lock (the default context's lockdir) was generated. $ rm -rf *.lock Generate the lockdir for the non-default context. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=foo + $ dune pkg lock --context=foo Solution for bar.lock: - bar.0.5.0 - baz.0.1.0 @@ -99,7 +107,7 @@ Now only bar.lock was generated. $ rm -rf *.lock Generate the lockdir for a context which prefers oldest package versions. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=prefers_oldest + $ dune pkg lock --context=prefers_oldest Solution for prefers_oldest.lock: - bar.0.4.0 - baz.0.1.0 @@ -107,14 +115,14 @@ Generate the lockdir for a context which prefers oldest package versions. Re-generate the lockdir for a context which prefers oldest package versions, but override it to prefer newest with a command line argument. - $ dune pkg lock --opam-repository-path=mock-opam-repository --context=prefers_oldest --version-preference=newest + $ dune pkg lock --context=prefers_oldest --version-preference=newest Solution for prefers_oldest.lock: - bar.0.5.0 - baz.0.1.0 - foo.0.0.1 Generate the lockdir for all (non-opam) contexts. - $ dune pkg lock --opam-repository-path=mock-opam-repository --all-contexts + $ dune pkg lock --all-contexts Solution for prefers_oldest.lock: - bar.0.4.0 - baz.0.1.0 diff --git a/test/blackbox-tests/test-cases/pkg/lockdir-tampering.t b/test/blackbox-tests/test-cases/pkg/lockdir-tampering.t index c9979915924..3718106b127 100644 --- a/test/blackbox-tests/test-cases/pkg/lockdir-tampering.t +++ b/test/blackbox-tests/test-cases/pkg/lockdir-tampering.t @@ -25,13 +25,21 @@ Define some local packages. > (package (name foo) (depends a (b (>= 0.0.2)))) > (package (name bar) (depends foo c)) > EOF + $ cat >dune-workspace < (lang dune 3.11) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) + > EOF Without a lockdir this command prints a hint but exits successfully. $ dune pkg validate-lockdir No lockdirs to validate. Make the lockdir. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 @@ -67,7 +75,7 @@ Remove the file but corrupt the lockdir metadata file. Regenerate the lockdir and validate the result. $ rm -r dune.lock - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 @@ -93,7 +101,7 @@ This results in an invalid lockdir due to the missing package. [1] Regenerate the lockdir and validate the result. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 @@ -124,7 +132,7 @@ Now the lockdir is invalid as it doesn't contain the right version of "b". [1] Regenerate the lockdir and validate the result. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 @@ -150,7 +158,7 @@ The lockdir is invalid as the package "b" is now defined both locally and in the [1] Regenerate the lockdir and validate the result. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 @@ -177,7 +185,7 @@ The lockdir is invalid as it contains unnecessary packages. [1] Regenerate the lockdir and validate the result. - $ dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository + $ dune pkg lock --dont-poll-system-solver-variables Solution for dune.lock: - a.0.0.1 - b.0.0.2 diff --git a/test/blackbox-tests/test-cases/pkg/lockfile-generation.t/run.t b/test/blackbox-tests/test-cases/pkg/lockfile-generation.t/run.t index bfe7d31e49b..19d8a64fbbc 100644 --- a/test/blackbox-tests/test-cases/pkg/lockfile-generation.t/run.t +++ b/test/blackbox-tests/test-cases/pkg/lockfile-generation.t/run.t @@ -28,10 +28,18 @@ Generate a `dune-project` file. > "bar" {>= "0.2"} > ] > EOF + > cat >dune-workspace < (lang dune 3.8) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) + > EOF Run the solver and generate a lock directory. - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: - bar.0.5.0 - baz.0.1.0 @@ -81,7 +89,7 @@ Print the contents of each file in the lockdir: Run the solver again preferring oldest versions of dependencies: - $ dune pkg lock --version-preference=oldest --opam-repository-path=mock-opam-repository + $ dune pkg lock --version-preference=oldest Solution for dune.lock: - bar.0.4.0 - baz.0.1.0 @@ -136,7 +144,7 @@ Regenerate the `dune-project` file introducing an unsatisfiable constraint. > EOF Run the solver again. This time it will fail. - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Error: Unable to solve dependencies in build context: default Can't find all required versions. Selected: baz.0.1.0 foo.0.0.1 lockfile_generation_test.dev @@ -166,7 +174,7 @@ should pick one of them. After running this we expact a solution that has either `bar` or `baz` but not both. - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: - bar.0.5.0 - bar-or-baz.0.0.1 @@ -190,7 +198,7 @@ patterns that can't be simplified After runninng we expect the solution to have quux and either baz or quz as well as bar or qux. - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: - bar.0.5.0 - baz.0.1.0 @@ -210,7 +218,7 @@ in between. > depends: [ ("bar" & "quux") | "baz" ] > EOF - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: - bar.0.5.0 - priorities.0.0.1 @@ -237,7 +245,7 @@ versions 1 or 3, as well as making sure it doesn't pick the newest version. With versions 1 and 3 negated and version 4 removed via version constraint, we'd expect version 2 to be chosen: - $ dune pkg lock --opam-repository-path=mock-opam-repository + $ dune pkg lock Solution for dune.lock: - negation.0.0.1 - pkg.2 diff --git a/test/blackbox-tests/test-cases/pkg/opam-repository-download.t b/test/blackbox-tests/test-cases/pkg/opam-repository-download.t index 14c6e99992f..70fa8e7d79a 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-repository-download.t +++ b/test/blackbox-tests/test-cases/pkg/opam-repository-download.t @@ -19,15 +19,23 @@ Make a mock repo tarball that will get used by dune to download the package $ mkdir fake-xdg-cache $ cat > dune-project < (lang dune 3.8) + > (lang dune 3.10) > (generate_opam_files true) > > (package > (name baz) > (depends bar)) > EOF + $ cat > dune-workspace < (lang dune 3.10) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "git+file://$(pwd)/mock-opam-repository")) + > EOF - $ XDG_CACHE_HOME=$(pwd)/fake-xdg-cache dune pkg lock --opam-repository-url=git+file://$(pwd)/mock-opam-repository + $ XDG_CACHE_HOME=$(pwd)/fake-xdg-cache dune pkg lock Solution for dune.lock: - bar.0.0.1 - foo.0.0.1 @@ -45,11 +53,19 @@ reproducible) $ grep "git_hash $REPO_HASH" dune.lock/lock.dune > /dev/null -Now try it with an a path, given it is not a URL, it can't be reproduced on +Now try it with an a path. Given it is not a git URL, it can't be reproduced on other systems and thus shouldn't be included. $ rm -r dune.lock - $ dune pkg lock --opam-repository-path=$(pwd)/mock-opam-repository + $ cat > dune-workspace < (lang dune 3.10) + > (lock_dir + > (repositories mock)) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) + > EOF + $ dune pkg lock Solution for dune.lock: - bar.0.0.1 - foo.0.0.1 diff --git a/test/blackbox-tests/test-cases/pkg/outdated.t b/test/blackbox-tests/test-cases/pkg/outdated.t index d5d3815d6ff..28fe282b41b 100644 --- a/test/blackbox-tests/test-cases/pkg/outdated.t +++ b/test/blackbox-tests/test-cases/pkg/outdated.t @@ -1,7 +1,7 @@ $ . ./helpers.sh $ outdated () { - > dune pkg outdated --opam-repository-path=mock-opam-repository $@ + > dune pkg outdated $@ > } `dune pkg outdated` lists the outdated packages in the current project. @@ -12,12 +12,20 @@ > EOF $ cat > dune-workspace < (lang dune 3.11) + > (lock_dir + > (repositories mock)) + > (lock_dir + > (path dune.workspace.lock) + > (repositories mock)) > (context > (default)) > (context > (default > (name workspace-context) > (lock_dir dune.workspace.lock))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF $ solve_project --all-contexts < (lang dune 3.11) diff --git a/test/blackbox-tests/test-cases/pkg/partial-filter-evaluation.t b/test/blackbox-tests/test-cases/pkg/partial-filter-evaluation.t index 3786de900f3..329386f7eaa 100644 --- a/test/blackbox-tests/test-cases/pkg/partial-filter-evaluation.t +++ b/test/blackbox-tests/test-cases/pkg/partial-filter-evaluation.t @@ -52,6 +52,7 @@ Make a custom solver env: > (lang dune 3.8) > (lock_dir > (path dune.lock) + > (repositories mock) > (solver_env > (dev false) > (with-doc true) @@ -60,6 +61,9 @@ Make a custom solver env: > (default > (name default) > (lock_dir dune.lock))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Run the solver using the new env: diff --git a/test/blackbox-tests/test-cases/pkg/solver-vars-in-lockdir-metadata.t b/test/blackbox-tests/test-cases/pkg/solver-vars-in-lockdir-metadata.t index 49c439d8c70..8a0d58cfb69 100644 --- a/test/blackbox-tests/test-cases/pkg/solver-vars-in-lockdir-metadata.t +++ b/test/blackbox-tests/test-cases/pkg/solver-vars-in-lockdir-metadata.t @@ -90,12 +90,16 @@ Make a workspace file which sets some of the variables. > (lang dune 3.8) > (lock_dir > (path dune.lock) + > (repositories mock) > (solver_env > (os linux) > (arch arm))) > (context > (default > (name default))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF Solve the packages again, this time with the variables set. diff --git a/test/blackbox-tests/test-cases/pkg/unavailable-packages.t b/test/blackbox-tests/test-cases/pkg/unavailable-packages.t index 40a3070b425..85bd84e7156 100644 --- a/test/blackbox-tests/test-cases/pkg/unavailable-packages.t +++ b/test/blackbox-tests/test-cases/pkg/unavailable-packages.t @@ -6,10 +6,12 @@ Set up two build contexts: a default one for linux and another for macos. > (lang dune 3.8) > (lock_dir > (path dune.lock) + > (repositories mock) > (solver_env > (os linux))) > (lock_dir > (path dune.macos.lock) + > (repositories mock) > (solver_env > (os macos))) > (context (default)) @@ -17,14 +19,17 @@ Set up two build contexts: a default one for linux and another for macos. > (default > (name macos) > (lock_dir dune.macos.lock))) + > (repository + > (name mock) + > (source "file://$(pwd)/mock-opam-repository")) > EOF !! Do not delete this one for the one in helpers.sh as it passes --context !! Helper shell function to generate a dune-project file and generate lockdir for both contexts: $ solve_project() { > cat >dune-project - > dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository --context=default - > dune pkg lock --dont-poll-system-solver-variables --opam-repository-path=mock-opam-repository --context=macos + > dune pkg lock --dont-poll-system-solver-variables --context=default + > dune pkg lock --dont-poll-system-solver-variables --context=macos > } A package which is only available on linux: