From 3c89526693391b9a9b40bed938c68f49f2ddb783 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Sat, 28 Oct 2023 11:48:16 +0200 Subject: [PATCH] Add pin-depends tests --- test/bin/pin-depends.t/duniverse/b/b.opam | 1 + test/bin/pin-depends.t/pin-depends.opam | 12 ++++ .../pin-depends.t/repo/packages/b/b.1/opam | 12 ++++ .../pin-depends.t/repo/packages/c/c.1/opam | 12 ++++ test/bin/pin-depends.t/repo/repo | 1 + test/bin/pin-depends.t/run.t | 66 +++++++++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 test/bin/pin-depends.t/duniverse/b/b.opam create mode 100644 test/bin/pin-depends.t/pin-depends.opam create mode 100644 test/bin/pin-depends.t/repo/packages/b/b.1/opam create mode 100644 test/bin/pin-depends.t/repo/packages/c/c.1/opam create mode 100644 test/bin/pin-depends.t/repo/repo create mode 100644 test/bin/pin-depends.t/run.t diff --git a/test/bin/pin-depends.t/duniverse/b/b.opam b/test/bin/pin-depends.t/duniverse/b/b.opam new file mode 100644 index 000000000..013b84db6 --- /dev/null +++ b/test/bin/pin-depends.t/duniverse/b/b.opam @@ -0,0 +1 @@ +opam-version: "2.0" diff --git a/test/bin/pin-depends.t/pin-depends.opam b/test/bin/pin-depends.t/pin-depends.opam new file mode 100644 index 000000000..813215301 --- /dev/null +++ b/test/bin/pin-depends.t/pin-depends.opam @@ -0,0 +1,12 @@ +opam-version: "2.0" +depends: [ + "dune" + "b" + "c" +] +pin-depends: ["b.dev" "./duniverse/b"] +x-opam-monorepo-opam-provided: ["b"] +x-opam-monorepo-opam-repositories: [ + "file://$OPAM_MONOREPO_CWD/minimal-repo" + "file://$OPAM_MONOREPO_CWD/repo" +] diff --git a/test/bin/pin-depends.t/repo/packages/b/b.1/opam b/test/bin/pin-depends.t/repo/packages/b/b.1/opam new file mode 100644 index 000000000..7442b0a1d --- /dev/null +++ b/test/bin/pin-depends.t/repo/packages/b/b.1/opam @@ -0,0 +1,12 @@ +opam-version: "2.0" +depends: [ + "dune" +] +build: [ "dune" "build" ] +dev-repo: "git+https://github.com/b/b" +url { + src: "https://b.com/b.tbz" + checksum: [ + "sha256=0000000000000000000000000000000000000000000000000000000000000000" + ] +} diff --git a/test/bin/pin-depends.t/repo/packages/c/c.1/opam b/test/bin/pin-depends.t/repo/packages/c/c.1/opam new file mode 100644 index 000000000..821b718c6 --- /dev/null +++ b/test/bin/pin-depends.t/repo/packages/c/c.1/opam @@ -0,0 +1,12 @@ +opam-version: "2.0" +depends: [ + "dune" +] +build: [ "dune" "build" ] +dev-repo: "git+https://github.com/c/c" +url { + src: "https://c.com/c.tbz" + checksum: [ + "sha256=0000000000000000000000000000000000000000000000000000000000000001" + ] +} diff --git a/test/bin/pin-depends.t/repo/repo b/test/bin/pin-depends.t/repo/repo new file mode 100644 index 000000000..013b84db6 --- /dev/null +++ b/test/bin/pin-depends.t/repo/repo @@ -0,0 +1 @@ +opam-version: "2.0" diff --git a/test/bin/pin-depends.t/run.t b/test/bin/pin-depends.t/run.t new file mode 100644 index 000000000..ca314db9b --- /dev/null +++ b/test/bin/pin-depends.t/run.t @@ -0,0 +1,66 @@ +We have a simple project with a single package defined at the root. +It has a `x-opam-monorepo-opam-repositories` field set to use a local +opam-repository for locking and a pinned package. + + $ cat pin-depends.opam + opam-version: "2.0" + depends: [ + "dune" + "b" + "c" + ] + pin-depends: ["b.dev" "./duniverse/b"] + x-opam-monorepo-opam-provided: ["b"] + x-opam-monorepo-opam-repositories: [ + "file://$OPAM_MONOREPO_CWD/minimal-repo" + "file://$OPAM_MONOREPO_CWD/repo" + ] + +We provided a minimal opam-repository but locking should be successful. + + $ gen-minimal-repo + $ opam-monorepo lock + ==> Using 1 locally scanned package as the target. + ==> Found 10 opam dependencies for the target package. + ==> Querying opam database for their metadata and Dune compatibility. + ==> Calculating exact pins for each of them. + ==> Wrote lockfile with 1 entries to $TESTCASE_ROOT/pin-depends.opam.locked. You can now run opam monorepo pull to fetch their sources. + +The lockfile should contain the base packages, dune and our 2 dependencies +`b` and `c` which should be pulled in the duniverse + + $ cat pin-depends.opam.locked | sed 's|file://.*/pin-depends.t/|file://$LOCAL_PATH/|' + opam-version: "2.0" + synopsis: "opam-monorepo generated lockfile" + maintainer: "opam-monorepo" + depends: [ + "b" {= "dev"} + "base-bigarray" {= "base"} + "base-threads" {= "base"} + "base-unix" {= "base"} + "c" {= "1" & ?vendor} + "dune" {= "2.9.1"} + "ocaml" {= "4.13.1"} + "ocaml-base-compiler" {= "4.13.1"} + "ocaml-config" {= "2"} + "ocaml-options-vanilla" {= "1"} + ] + pin-depends: [ + "b.dev" + "file://$LOCAL_PATH/duniverse/b" + ] + x-opam-monorepo-duniverse-dirs: [ + [ + "https://c.com/c.tbz" + "c" + [ + "sha256=0000000000000000000000000000000000000000000000000000000000000001" + ] + ] + ] + x-opam-monorepo-opam-provided: ["b"] + x-opam-monorepo-opam-repositories: [ + "file://$OPAM_MONOREPO_CWD/minimal-repo" "file://$OPAM_MONOREPO_CWD/repo" + ] + x-opam-monorepo-root-packages: ["pin-depends"] + x-opam-monorepo-version: "0.3"