Skip to content

Commit

Permalink
reftest: add build env test that defined and overridden opam variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Feb 15, 2023
1 parent cb38bab commit e799424
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions tests/reftests/env.test
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,85 @@ NV_VARS4='': export NV_VARS4:
### opam exec -- opam env --revert | grep "NV_VARS" | ';' -> ':'
NV_VARS3='/yet/another/different/path': export NV_VARS3:
NV_VARS4='': export NV_VARS4:
### : Build environment variables and their overwrite :
### # Note: OPAMROOT is not shown as it is defined in the environment
### # MANPATH is not kept, it is supposed to have the same behaviour thant PATH
### sh -c "env | sort | uniq" >$ LOCALENV
### <pkg:to-build.2>
opam-version: "2.0"
build: [ "sh" "getenv.sh" "1" ]
### <pkg:to-build.2:getenv.sh>
out=build-env
fromtest="^PATH=\|^MANPATH=\|^LOCALENV=\|^TEMPDIR=\|^TMPDIR=\|^TMP=\|^TEMP=\|^SHLVL=\|^PWD=\|^_="
for v in $LOCALENV; do
if echo $v | grep -q "=" ; then
fromtest="$fromtest\\|^`echo $v | cut -f 1 -d '='`="
fi
done
env | sort | uniq | grep -v "'$fromtest'"> $out
echo "PATH=`echo $PATH | cut -f $1 -d ':'`" >> $out

echo "doc: [ \"$out\"]" > to-build.install
### opam switch create bd --empty
### opam install to-build
The following actions will be performed:
=== install 1 package
- install to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed to-build.2
Done.
### cat $OPAMROOT/bd/doc/to-build/build-env
CDPATH=
MAKEFLAGS=
MAKELEVEL=
OPAMCLI=2.0
OPAMSWITCH=bd
OPAM_PACKAGE_NAME=to-build
OPAM_PACKAGE_VERSION=2
OPAM_SWITCH_PREFIX=${BASEDIR}/OPAM/bd
PATH=${BASEDIR}/OPAM/bd/bin
### opam remove to-build
The following actions will be performed:
=== remove 1 package
- remove to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed to-build.2
Done.
### <pkg:to-build.2>
opam-version: "2.0"
build: [ "sh" "getenv.sh" "1-2" ]
build-env: [
[ CDPATH = "another-cdpath" ]
[ MAKEFLAGS = "another-makeflags" ]
[ MAKELEVEL = "another-makelevel" ]
[ OPAMCLI="1.0" ]
[ OPAMROOT="another-root" ]
[ OPAMSWITCH="another-switch" ]
[ OPAM_PACKAGE_NAME="another-package" ]
[ OPAM_PACKAGE_VERSION="another-version" ]
[ OPAM_SWITCH_PREFIX="another-switch-prefix" ]
[ PATH+="another-path" ]
]
### opam install to-build
The following actions will be performed:
=== install 1 package
- install to-build 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed to-build.2
Done.
### cat $OPAMROOT/bd/doc/to-build/build-env
CDPATH=another-cdpath
MAKEFLAGS=another-makeflags
MAKELEVEL=another-makelevel
OPAMCLI=1.0
OPAMSWITCH=bd
OPAM_PACKAGE_NAME=another-package
OPAM_PACKAGE_VERSION=another-version
OPAM_SWITCH_PREFIX=${BASEDIR}/OPAM/bd
PATH=${BASEDIR}/OPAM/bd/bin:another-path
### : root and switch with spaces :
### RT="$BASEDIR/root 2"
### SW="switch w spaces"
Expand Down

0 comments on commit e799424

Please sign in to comment.