Skip to content

Commit 7087731

Browse files
committed
reftest: add a test for git packages with submodules
1 parent 2ee2c1b commit 7087731

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

master_changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ users)
157157
* Add a test showing the behaviour of `opam list --latests-only` [#5375 @kit-ty-kate]
158158
* Add a test filtering mechanism [#6105 @Keryan-dev]
159159
* Add a package fetching test [#6146 @rjbou]
160+
* Add a test for git packages with submodules [#6132 @kit-ty-kate]
160161

161162
### Engine
162163
* Add a test filtering mechanism [#6105 @Keryan-dev]

tests/reftests/dune.inc

+18
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,24 @@
818818
%{targets}
819819
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:filter-operators.test} %{read-lines:testing-env}))))
820820

821+
(rule
822+
(alias reftest-git)
823+
(action
824+
(diff git.test git.out)))
825+
826+
(alias
827+
(name reftest)
828+
(deps (alias reftest-git)))
829+
830+
(rule
831+
(targets git.out)
832+
(deps root-N0REP0)
833+
(package opam)
834+
(action
835+
(with-stdout-to
836+
%{targets}
837+
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:git.test} %{read-lines:testing-env}))))
838+
821839
(rule
822840
(alias reftest-init-ocaml-eval-variables.unix)
823841
(enabled_if (and (= %{os_type} "Unix") (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))

tests/reftests/git.test

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
N0REP0
2+
### : Check the bevahiour when presented with a broken submodule
3+
### mkdir submodule
4+
### git -C ./submodule init -q
5+
### git -C ./submodule config core.autocrlf false
6+
### touch ./submodule/some-file
7+
### git -C ./submodule add ./some-file
8+
### git -C ./submodule commit -qm "first commit"
9+
### mkdir use-submodule
10+
### git -C ./use-submodule init -q
11+
### git -C ./use-submodule config core.autocrlf false
12+
### git -C ./use-submodule submodule add ../submodule ./vendor
13+
Cloning into '${BASEDIR}/use-submodule/vendor'...
14+
done.
15+
### git -C ./use-submodule commit -qm "first commit"
16+
### <create-submodule-pkg.sh>
17+
mkdir -p REPO/packages/submodule/submodule.1
18+
cat > REPO/packages/submodule/submodule.1/opam << EOF
19+
opam-version: "2.0"
20+
build: ["ls" "vendor/some-file"]
21+
url {
22+
src: "git+file://${BASEDIR}/use-submodule"
23+
}
24+
EOF
25+
### sh ./create-submodule-pkg.sh
26+
### opam update
27+
28+
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
29+
[default] synchronised from file://${BASEDIR}/REPO
30+
Now run 'opam upgrade' to apply any package updates.
31+
### opam switch create submodule --empty
32+
### opam install --verbose submodule
33+
The following actions will be performed:
34+
=== install 1 package
35+
- install submodule 1
36+
37+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
38+
Processing 1/3: [submodule.1: git]
39+
-> retrieved submodule.1 (git+file://${BASEDIR}/use-submodule)
40+
Processing 2/3: [submodule: ls]
41+
+ ${BASEDIR}/OPAM/opam-init/hooks/sandbox.sh "build" "ls" "vendor/some-file" (CWD=${BASEDIR}/OPAM/submodule/.opam-switch/build/submodule.1)
42+
- vendor/some-file
43+
-> compiled submodule.1
44+
-> installed submodule.1
45+
Done.
46+
### rm -r ./submodule
47+
### opam remove submodule
48+
The following actions will be performed:
49+
=== remove 1 package
50+
- remove submodule 1
51+
52+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
53+
-> removed submodule.1
54+
Done.
55+
### opam install --verbose submodule
56+
The following actions will be performed:
57+
=== install 1 package
58+
- install submodule 1
59+
60+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
61+
Processing 1/3: [submodule.1: git]
62+
[WARNING] Git submodule update failed in ${BASEDIR}/OPAM/submodule/.opam-switch/sources/submodule.1
63+
-> retrieved submodule.1 (git+file://${BASEDIR}/use-submodule)
64+
Processing 2/3: [submodule: ls]
65+
+ ${BASEDIR}/OPAM/opam-init/hooks/sandbox.sh "build" "ls" "vendor/some-file" (CWD=${BASEDIR}/OPAM/submodule/.opam-switch/build/submodule.1)
66+
- ls: cannot access 'vendor/some-file': No such file or directory
67+
[ERROR] The compilation of submodule.1 failed at "ls vendor/some-file".
68+
69+
##% output ###
70+
# ls: cannot access 'vendor/some-file': No such file or directory
71+
72+
73+
74+
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
75+
+- The following actions failed
76+
| - build submodule 1
77+
+-
78+
- No changes have been performed
79+
'${OPAM} install --verbose submodule' failed.
80+
# Return code 31 #

0 commit comments

Comments
 (0)