Skip to content

Commit

Permalink
test(pkg): Extend the test to use recursive submodules
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Kubica <marek@tarides.com>
  • Loading branch information
Leonidas-from-XIV committed Feb 26, 2024
1 parent a2ca767 commit a509ac4
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 59 deletions.
59 changes: 0 additions & 59 deletions test/blackbox-tests/test-cases/pkg/opam-repository-download.t
Original file line number Diff line number Diff line change
Expand Up @@ -227,62 +227,3 @@ So we should get `bar.1.0.0` when locking.
Solution for dune.lock:
- bar.1.0.0
- foo.0.1.0
We want to make sure locking works even with submodules:
$ rm -r mock-opam-repository
$ mkrepo
$ mkpkg foo <<EOF
> EOF
$ mkpkg bar <<EOF
> depends: [ "foo" ]
> EOF
We move `packages` into a different folder
$ mkdir remote-submodule
$ mv mock-opam-repository/packages/* remote-submodule
$ rm -r mock-opam-repository/packages
And create it as a separate repo, this time with the packages in the root:
$ cd remote-submodule
$ git init --quiet
$ git add -A
$ git commit -m "Initial subrepo commit" --quiet
$ SUBMODULE_REVISION=$(git rev-parse HEAD)
$ SUBMODULE_LOCATION=$(pwd)
$ cd ..
In our mock repository, we make sure to add the submodule as `packages`:
$ cd mock-opam-repository
$ git init --quiet
$ GIT_ALLOW_PROTOCOL=file git submodule add ${SUBMODULE_LOCATION} packages
Cloning into '$TESTCASE_ROOT/mock-opam-repository/packages'...
done.
$ git commit -m "Initial opam-repo commit" --quiet
$ git submodule init
$ git ls-tree -r HEAD | grep "commit ${SUBMODULE_REVISION}" > /dev/null && echo "Submodule exists at expected revision"
Submodule exists at expected revision
$ cd ..
We'll use the mock repository as source:
$ cat > dune-workspace <<EOF
> (lang dune 3.10)
> (repository
> (name mock)
> (source "git+file://$(pwd)/mock-opam-repository"))
> (lock_dir
> (repositories mock))
> EOF
We should be able to successfully solve the project with `foo` and `bar`,
however due to some issues this currently fails:
$ rm -r dune.lock
$ dune pkg lock
Solution for dune.lock:
- bar.0.0.1
- foo.0.0.1
81 changes: 81 additions & 0 deletions test/blackbox-tests/test-cases/pkg/submodules.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
We want to make sure locking works even with submodules. Submodules can
contains submodules on their own which should also work.

$ . ./helpers.sh
$ mkrepo
$ mkpkg foo <<EOF
> EOF
$ mkpkg bar <<EOF
> depends: [ "foo" ]
> EOF
We move `packages` into a different folder
$ mkdir remote-submodule
$ mv mock-opam-repository/packages/* remote-submodule
$ rm -r mock-opam-repository/packages
We also move `bar` to a different subrepo:
$ mv remote-submodule/bar remote-bar
And create a tree of repos with each of them referencing each other. First we
create a regular repo containing `bar`
$ cd remote-bar
$ git init --quiet
$ git add -A
$ git commit -m "Initial commit of bar package" --quiet
$ SUBMODULE_BAR_LOCATION=$(pwd)
$ cd ..
Then we add the `bar` repo as submodule of the `packages` repo:
$ cd remote-submodule
$ git init --quiet
$ git add -A
$ GIT_ALLOW_PROTOCOL=file git submodule add ${SUBMODULE_BAR_LOCATION} bar
Cloning into '$TESTCASE_ROOT/remote-submodule/bar'...
done.
$ git commit -m "Initial subrepo commit" --quiet
$ SUBMODULE_REVISION=$(git rev-parse HEAD)
$ SUBMODULE_LOCATION=$(pwd)
$ cd ..
In our mock repository, we make sure to add the package submodule as
`packages` folder:
$ cd mock-opam-repository
$ git init --quiet
$ GIT_ALLOW_PROTOCOL=file git submodule add ${SUBMODULE_LOCATION} packages
Cloning into '$TESTCASE_ROOT/mock-opam-repository/packages'...
done.
$ git commit -m "Initial opam-repo commit" --quiet
$ git submodule init
$ git ls-tree -r HEAD | grep "commit ${SUBMODULE_REVISION}" > /dev/null && echo "Submodule exists at expected revision"
Submodule exists at expected revision
$ cd ..
We'll use the mock repository as source and depend on `bar`:
$ cat > dune-workspace <<EOF
> (lang dune 3.10)
> (repository
> (name mock)
> (source "git+file://$(pwd)/mock-opam-repository"))
> (lock_dir
> (repositories mock))
> EOF
$ cat > dune-project <<EOF
> (lang dune 3.10)
> (package
> (name baz)
> (depends bar))
> EOF
We should be able to successfully solve the project with `foo` and `bar`:
$ dune pkg lock
Solution for dune.lock:
- bar.0.0.1
- foo.0.0.1

0 comments on commit a509ac4

Please sign in to comment.