Skip to content

Commit

Permalink
Merge pull request #29 from hernoufM/test
Browse files Browse the repository at this point in the history
Add tests
  • Loading branch information
rjbou committed May 3, 2023
2 parents b641539 + 2b0cf41 commit 2dac5f5
Show file tree
Hide file tree
Showing 12 changed files with 2,039 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ jobs:

- run: opam install . --deps-only --with-test
- run: opam exec -- make
- run: ./opam-bundle --help
- run: opam exec -- make stub-tests
- run: opam exec -- make real-tests
if: matrix.ocaml-compiler == '4.14.x'
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ build:
dune build
cp _build/install/default/bin/opam-bundle .

stub-tests:
dune build @runtest tests/stub

real-tests:
dune build @runtest tests/real

.PHONY: tests
tests: stub-tests real-tests
test: tests

.PHONY: clean
clean:
dune clean
Expand Down
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(lang dune 2.7)
(name opam-bundle)
(cram enable)
2 changes: 1 addition & 1 deletion opam-bundle.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ depends: [
"cmdliner" {build & >= "1.1.0"}
"opam-client" {build & >= "2.1.0"}
]
build: [ "dune" "build" "-j" jobs "-p" name ]
build: [ "dune" "build" "-j" jobs "-p" name "@runtest" {with-test} ]
dev-repo: "git+https://github.com/AltGr/opam-bundle"
flags: plugin
synopsis: "A tool that creates stand-alone source bundles from opam packages"
Expand Down
2 changes: 1 addition & 1 deletion shell/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ EOF
chmod +x ${PREFIX}/bin/sudo

R=0
logged_cmd "Compiling packages" opam install --confirm=unsafe-yes %{install_packages}% %{doc?--with-doc:}% %{test?--with-test:}% || R=$?
logged_cmd "Compiling packages" opam install --yes %{install_packages}% %{doc?--with-doc:}% %{test?--with-test:}% || R=$?

rm -f ${PREFIX}/bin/sudo

Expand Down
3 changes: 3 additions & 0 deletions tests/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(cram
(applies_to :whole_subtree)
(deps %{bin:opam-bundle}))
122 changes: 122 additions & 0 deletions tests/real/odoc.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
This test verify bundling of real package `odoc` with compiler version 4.02.3 and opam version 2.0.

$ export OPAMNOENVNOTICE=1
$ export OPAMYES=1
$ export OPAMROOT=$PWD/OPAMROOT
$ export OPAMSTATUSLINE=never
$ export OPAMVERBOSE=-1
$ opam --version
2.1.4
$ opam-bundle odoc --ocaml=4.02.3 --opam=2.0 --self --yes 2>&1 | sed 's/arch =.*/arch = $ARCH/;s/os =.*/os = $OS/;s/os-distribution =.*/os-distribution = $OSDISTRIB/;s/os-version =.*/os-version = $OSVERSION/;s/os-family =.*/os-family = $OSFAMILLY/'
No environment specified, will use the following for package resolution (based on the host system):
- arch = $ARCH
- os = $OS
- os-distribution = $OSDISTRIB
- os-version = $OSVERSION
- os-family = $OSFAMILLY

<><> Initialising repositories ><><><><><><><><><><><><><><><><><><><><><><><><>
[opam.ocaml.org] Initialised

<><> Resolving package set ><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] No solution for odoc & ocaml-bootstrap.4.02.3: * Incompatible packages:
- ocaml-bootstrap
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler < 3.08 -> ocaml < 4.02.3
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml < 4.02.3
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.03.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.04.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.04.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.04.2
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.05.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.06.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.06.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.07.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.07.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.08.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.08.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.09.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.09.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.10.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.10.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.10.2
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.11.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.11.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.11.2
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.12.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.12.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.13.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.13.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.14.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 4.14.1
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 5.0.0
no matching version
* Missing dependency:
- ocaml-bootstrap -> ocaml -> ocaml-config -> ocaml-base-compiler >= 3.08.0~ -> ocaml >= 5.01.0
no matching version


$ sh ./odoc-bundle.sh -y
sh: 0: cannot open ./odoc-bundle.sh: No such file
[2]
$ sh ./odoc-bundle/compile.sh ../ODOC
sh: 0: cannot open ./odoc-bundle/compile.sh: No such file
[2]
$ ODOC/bin/odoc
ODOC/bin/odoc: not found
[127]
72 changes: 72 additions & 0 deletions tests/real/opam-bundle.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
This test verify bundling of real package `opam-bundle` of version 0.4.

$ export OPAMNOENVNOTICE=1
$ export OPAMYES=1
$ export OPAMROOT=$PWD/OPAMROOT
$ export OPAMSTATUSLINE=never
$ export OPAMVERBOSE=-1
$ opam --version
2.1.4
$ opam-bundle "opam-bundle@https://github.com/AltGr/opam-bundle/archive/refs/tags/0.4.tar.gz" opam-client.2.0.10 --self --opam=2.1 --ocaml=4.14.0 --yes 2>&1 | sed 's/arch =.*/arch = $ARCH/;s/os =.*/os = $OS/;s/os-distribution =.*/os-distribution = $OSDISTRIB/;s/os-version =.*/os-version = $OSVERSION/;s/os-family =.*/os-family = $OSFAMILLY/'
No environment specified, will use the following for package resolution (based on the host system):
- arch = $ARCH
- os = $OS
- os-distribution = $OSDISTRIB
- os-version = $OSVERSION
- os-family = $OSFAMILLY

<><> Initialising repositories ><><><><><><><><><><><><><><><><><><><><><><><><>
[opam.ocaml.org] Initialised

<><> Getting external packages ><><><><><><><><><><><><><><><><><><><><><><><><>
[NOTE] Will use package definition found in source for opam-bundle

<><> Resolving package set ><><><><><><><><><><><><><><><><><><><><><><><><><><>
The following packages will be included:
- base-bigarray.base
- base-bytes.base
- base-threads.base
- base-unix.base
- cmdliner.1.2.0
- cppo.1.6.9
- cudf.0.10
- dose3.5.0.1-2
- dune.3.7.1
- extlib.1.7.7-1
- mccs.1.1+14
- ocaml.4.14.0
- ocaml-base-compiler.4.14.0
- ocaml-bootstrap.4.14.0
- ocaml-config.2
- ocaml-options-vanilla.1
- ocamlbuild.0.14.2
- ocamlfind.1.9.6
- ocamlgraph.2.0.0
- opam-bundle.0.4
- opam-client.2.0.10
- opam-core.2.0.10
- opam-file-format.2.1.6
- opam-format.2.0.10
- opam-repository.2.0.10
- opam-solver.2.0.10
- opam-state.2.0.10
- re.1.10.4
- seq.base
- stdlib-shims.0.3.0
The bundle will be installable on systems matching the following: os != "win32"
[NOTE] Opam system sandboxing (introduced in 2.0) will be disabled in the bundle. You need to trust that the build scripts of the included packages don't write outside of their build directory and dest dir.
Continue ? [Y/n] y
<><> Getting all archives <><><><><><><><><><><><><><><><><><><><><><><><><><><>
<><> Getting bootstrap packages <><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Opam archive at https://github.com/ocaml/opam/releases/download/2.1/opam-full-2.1.tar.gz could not be obtained: curl error code 404
$ sh ./opam-bundle-bundle.sh -y
sh: 0: cannot open ./opam-bundle-bundle.sh: No such file
[2]
$ sh ./opam-bundle-bundle/compile.sh ../BUNDLE
sh: 0: cannot open ./opam-bundle-bundle/compile.sh: No such file
[2]
$ BUNDLE/bin/opam-bundle
BUNDLE/bin/opam-bundle: not found
[127]
Loading

0 comments on commit 2dac5f5

Please sign in to comment.