Skip to content

Commit

Permalink
reftest: add sandbox scripts test
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Aug 28, 2024
1 parent 6cbdfbb commit 51cb4ea
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ users)
* Add a test showing the behaviour of `opam switch list-available` [#6098 @kit-ty-kate]
* Add a test for git packages with submodules [#6132 @kit-ty-kate]
* Add basic test for `install --check` [#6122 @rjbou]
* Add a sandbox usage test [#6165 @rjbou]

### Engine
* Add a test filtering mechanism [#6105 @Keryan-dev]
Expand Down
21 changes: 21 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,27 @@
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:resolve-variables.test} %{read-lines:testing-env}))))

(rule
(alias reftest-sandbox.unix)
(enabled_if (and (= %{os_type} "Unix") (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(action
(diff sandbox.unix.test sandbox.unix.out)))

(alias
(name reftest)
(enabled_if (and (= %{os_type} "Unix") (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(deps (alias reftest-sandbox.unix)))

(rule
(targets sandbox.unix.out)
(deps root-N0REP0)
(enabled_if (and (= %{os_type} "Unix") (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(package opam)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:sandbox.unix.test} %{read-lines:testing-env}))))

(rule
(alias reftest-shared-fetch)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
Expand Down
35 changes: 35 additions & 0 deletions tests/reftests/sandbox.unix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
N0REP0
### <pkg:echo.1>
opam-version: "2.0"
build: [ "echo" "SUCCESS" "|" "tee" "check-write" ]
### <pkg:option.1>
opam-version: "2.0"
build: [ "opam" "option" "jobs=4" "--cli=2.1"]
### <pkg:var.1>
opam-version: "2.0"
build: [ "opam" "config" "var" "prefix" ]
### <pkg:tmp.1>
opam-version: "2.0"
build: [ "sh" "-c" "echo > /tmp/ech" ]
### <pkg:tmpdir.1>
opam-version: "2.0"
build: [ "sh" "-c" "echo > $TMPDIR/ech" ]
### opam switch create sdbx --empty
### OPAMVERBOSE=2
### opam install echo | grep "^\(\\+\|-) " | sed-cmd echo
+ echo "SUCCESS" "|" "tee" "check-write" (CWD=${BASEDIR}/OPAM/sdbx/.opam-switch/build/echo.1)
- SUCCESS | tee check-write
### opam install option | grep "^\(\\+\|-) " | '- .*opamMain.exe' -> '- opam' | sed-cmd opam
+ opam "option" "jobs=4" "--cli=2.1" (CWD=${BASEDIR}/OPAM/sdbx/.opam-switch/build/option.1)
- 'opam option jobs=4 --cli=2.1' failed.
- Fatal error:
- opam: "open" failed on ${BASEDIR}/OPAM/config.lock: Read-only file system
- No changes have been performed
# Return code 31 #
### opam install var | grep "^\(\\+\|-) " | sed-cmd opam
+ opam "config" "var" "prefix" (CWD=${BASEDIR}/OPAM/sdbx/.opam-switch/build/var.1)
- ${BASEDIR}/OPAM/sdbx
### opam install tmp | grep "^\(\\+\|-) " | sed-cmd sh
+ sh "-c" "echo > /tmp/ech" (CWD=${BASEDIR}/OPAM/sdbx/.opam-switch/build/tmp.1)
### opam install tmpdir | grep "^\(\\+\|-) " | sed-cmd sh
+ sh "-c" "echo > $TMPDIR/ech" (CWD=${BASEDIR}/OPAM/sdbx/.opam-switch/build/tmpdir.1)

0 comments on commit 51cb4ea

Please sign in to comment.