Skip to content

Commit

Permalink
Add pin-depends tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Oct 28, 2023
1 parent 05b530d commit bb8faf8
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/bin/pin-depends.t/#simple-lock.opam#
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
opam-version: "2.0"
depends: [
"dune"
"b"
"c"
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo"
"file://$OPAM_MONOREPO_CWD/repo"
]
1 change: 1 addition & 0 deletions test/bin/pin-depends.t/.#simple-lock.opam
14 changes: 14 additions & 0 deletions test/bin/pin-depends.t/pin-depends.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
opam-version: "2.0"
depends: [
"dune"
"b"
"c"
]
pin-depends:[
["a" "https://x"]
["base-bigarrays" "https://y"]
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo"
"file://$OPAM_MONOREPO_CWD/repo"
]
10 changes: 10 additions & 0 deletions test/bin/pin-depends.t/pin-depends.opam~
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
opam-version: "2.0"
depends: [
"dune"
"b"
"c"
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo"
"file://$OPAM_MONOREPO_CWD/repo"
]
12 changes: 12 additions & 0 deletions test/bin/pin-depends.t/repo/packages/b/b.1/opam
Original file line number Diff line number Diff line change
@@ -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"
]
}
12 changes: 12 additions & 0 deletions test/bin/pin-depends.t/repo/packages/c/c.1/opam
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions test/bin/pin-depends.t/repo/repo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opam-version: "2.0"
70 changes: 70 additions & 0 deletions test/bin/pin-depends.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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:[
["a" "https://x"]
["base-bigarrays" "https://y"]
]
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 2 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
opam-version: "2.0"
synopsis: "opam-monorepo generated lockfile"
maintainer: "opam-monorepo"
depends: [
"b" {= "1" & ?vendor}
"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"}
]
x-opam-monorepo-duniverse-dirs: [
[
"https://b.com/b.tbz"
"b"
[
"sha256=0000000000000000000000000000000000000000000000000000000000000000"
]
]
[
"https://c.com/c.tbz"
"c"
[
"sha256=0000000000000000000000000000000000000000000000000000000000000001"
]
]
]
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"
66 changes: 66 additions & 0 deletions test/bin/pin-depends.t/run.t~
Original file line number Diff line number Diff line change
@@ -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

$ cat simple-lock.opam
opam-version: "2.0"
depends: [
"dune"
"b"
"c"
]
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 2 entries to $TESTCASE_ROOT/simple-lock.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 simple-lock.opam.locked
opam-version: "2.0"
synopsis: "opam-monorepo generated lockfile"
maintainer: "opam-monorepo"
depends: [
"b" {= "1" & ?vendor}
"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"}
]
x-opam-monorepo-duniverse-dirs: [
[
"https://b.com/b.tbz"
"b"
[
"sha256=0000000000000000000000000000000000000000000000000000000000000000"
]
]
[
"https://c.com/c.tbz"
"c"
[
"sha256=0000000000000000000000000000000000000000000000000000000000000001"
]
]
]
x-opam-monorepo-opam-repositories: [
"file://$OPAM_MONOREPO_CWD/minimal-repo" "file://$OPAM_MONOREPO_CWD/repo"
]
x-opam-monorepo-root-packages: ["simple-lock"]
x-opam-monorepo-version: "0.3"

0 comments on commit bb8faf8

Please sign in to comment.