Skip to content

Commit

Permalink
reftest: add env rewriting rules test for unix & windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Aug 25, 2023
1 parent e1d2990 commit 05f6f4a
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,27 @@
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:env.test} %{read-lines:testing-env}))))

(rule
(alias reftest-env.unix)
(enabled_if (= %{os_type} "Unix"))
(action
(diff env.unix.test env.unix.out)))

(alias
(name reftest)
(enabled_if (= %{os_type} "Unix"))
(deps (alias reftest-env.unix)))

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

(rule
(alias reftest-env.win32)
(enabled_if (= %{os_type} "Win32"))
Expand Down
79 changes: 79 additions & 0 deletions tests/reftests/env.unix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
N0REP0
### : setenv & build env rewriting :
### opam switch create rewriting --empty
### <pkg:absent-rewrite.1>
opam-version: "2.0"
setenv: [ A_ENVSET = "/a/given/path" ]
build-env: [ A_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep A_ENV" ]
### opam install absent-rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install absent-rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [absent-rewrite: sh env | grep A_ENV]
sh "-c" "env | grep A_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/absent-rewrite.1)
- A_ENVBUILD=/another/given/path
-> compiled absent-rewrite.1
-> installed absent-rewrite.1
Done.
### opam env | grep "A_ENV"
A_ENVSET='/a/given/path'; export A_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/absent-rewrite.1/opam
build: ["sh" "-c" "env | grep A_ENV"]
build-env: A_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: A_ENVSET = "/a/given/path"
### <pkg:rewrite.1>
opam-version: "2.0"
setenv: [ R_ENVSET = "/a/given/path" ]
build-env: [ R_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep R_ENV" ]
x-allow-env-path-rewrite-on-windows: true
### opam install rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [rewrite: sh env | grep R_ENV]
sh "-c" "env | grep R_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1)
- R_ENVBUILD=/another/given/path
-> compiled rewrite.1
-> installed rewrite.1
Done.
### opam env | grep "R_ENV"
R_ENVSET='/a/given/path'; export R_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/rewrite.1/opam
build: ["sh" "-c" "env | grep R_ENV"]
build-env: R_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: R_ENVSET = "/a/given/path"
x-allow-env-path-rewrite-on-windows: true
### <pkg:no-rewrite.1>
opam-version: "2.0"
setenv: [ N_ENVSET = "/a/given/path" ]
build-env: [ N_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep N_ENV" ]
x-allow-env-path-rewrite-on-windows: false
### opam install no-rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install no-rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [no-rewrite: sh env | grep N_ENV]
sh "-c" "env | grep N_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/no-rewrite.1)
- N_ENVBUILD=/another/given/path
-> compiled no-rewrite.1
-> installed no-rewrite.1
Done.
### opam env | grep "N_ENV"
N_ENVSET='/a/given/path'; export N_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/no-rewrite.1/opam
build: ["sh" "-c" "env | grep N_ENV"]
build-env: N_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: N_ENVSET = "/a/given/path"
x-allow-env-path-rewrite-on-windows: false
79 changes: 79 additions & 0 deletions tests/reftests/env.win32.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,82 @@ The following actions will be performed:
Done.
### opam env | grep 'Foo|FOO' | "SET " -> "" | "'" -> "" | '; .*' -> ""
FOO=bar;foo
### : setenv & build env rewriting :
### opam switch create rewriting --empty
### <pkg:absent-rewrite.1>
opam-version: "2.0"
setenv: [ A_ENVSET = "/a/given/path" ]
build-env: [ A_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep A_ENV" ]
### opam install absent-rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install absent-rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [absent-rewrite: sh env | grep A_ENV]
sh "-c" "env | grep A_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/absent-rewrite.1)
- A_ENVBUILD=/another/given/path
-> compiled absent-rewrite.1
-> installed absent-rewrite.1
Done.
### opam env | grep "A_ENV"
A_ENVSET='/a/given/path'; export A_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/absent-rewrite.1/opam
build: ["sh" "-c" "env | grep A_ENV"]
build-env: A_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: A_ENVSET = "/a/given/path"
### <pkg:rewrite.1>
opam-version: "2.0"
setenv: [ R_ENVSET = "/a/given/path" ]
build-env: [ R_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep R_ENV" ]
x-allow-env-path-rewrite-on-windows: true
### opam install rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [rewrite: sh env | grep R_ENV]
sh "-c" "env | grep R_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/rewrite.1)
- R_ENVBUILD=\another\given\path
-> compiled rewrite.1
-> installed rewrite.1
Done.
### opam env | grep "R_ENV"
R_ENVSET='\a\given\path'; export R_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/rewrite.1/opam
build: ["sh" "-c" "env | grep R_ENV"]
build-env: R_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: R_ENVSET = "/a/given/path"
x-allow-env-path-rewrite-on-windows: true
### <pkg:no-rewrite.1>
opam-version: "2.0"
setenv: [ N_ENVSET = "/a/given/path" ]
build-env: [ N_ENVBUILD = "/another/given/path" ]
build: [ "sh" "-c" "env | grep N_ENV" ]
x-allow-env-path-rewrite-on-windows: false
### opam install no-rewrite -vv | sed-cmd sh
The following actions will be performed:
=== install 1 package
- install no-rewrite 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Processing 2/3: [no-rewrite: sh env | grep N_ENV]
sh "-c" "env | grep N_ENV" (CWD=${BASEDIR}/OPAM/rewriting/.opam-switch/build/no-rewrite.1)
- N_ENVBUILD=/another/given/path
-> compiled no-rewrite.1
-> installed no-rewrite.1
Done.
### opam env | grep "N_ENV"
N_ENVSET='/a/given/path'; export N_ENVSET;
### opam-cat OPAM/rewriting/.opam-switch/packages/no-rewrite.1/opam
build: ["sh" "-c" "env | grep N_ENV"]
build-env: N_ENVBUILD = "/another/given/path"
opam-version: "2.0"
setenv: N_ENVSET = "/a/given/path"
x-allow-env-path-rewrite-on-windows: false

0 comments on commit 05f6f4a

Please sign in to comment.