From 7e7388c28330a3ba1af496a9f34d73447691fe59 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Thu, 25 Apr 2024 13:55:56 +0100 Subject: [PATCH] Add regression test for #4861 As in this commit, there should be no output captured from the opam env --revert invocation. --- master_changes.md | 1 + tests/reftests/env.win32.test | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/master_changes.md b/master_changes.md index e71c0bcf5ca..2958e7a4bc1 100644 --- a/master_changes.md +++ b/master_changes.md @@ -121,6 +121,7 @@ users) * env tests: use `sort` to increase stability of the `opam env` output [#5935 @dra27 @rjbou] * env.win32: add mixed slashes test [#5935 @dra27] * env.win32: add test for environment revert not working correctly for Unix-like variables on Windows [#5935 @dra27] + * env.win32: add regression test for reverting additions to PATH-like variables [#5935 @dra27] ### Engine * Add `sort` command [#5935 @dra27] diff --git a/tests/reftests/env.win32.test b/tests/reftests/env.win32.test index df018e4a9ce..5ee2097cf2b 100644 --- a/tests/reftests/env.win32.test +++ b/tests/reftests/env.win32.test @@ -1,6 +1,31 @@ N0REP0 ### : setenv & build env rewriting : ### opam switch create rewriting --empty +### : Test for #4861 +### +opam-version: "2.0" +setenv: [ + [ PATH += "XXX:\\" ] + [ PATH += "C:\\Devel\\bin1;C:\\Devel\\bin2;C:\\Devel\\bin3;C:\\Devel\\bin4;ZZZ:\\" ] +] +x-env-path-rewrite: [ + [ PATH false ] +] +### opam install multipath -yv +The following actions will be performed: +=== install 1 package + - install multipath 1 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> installed multipath.1 +Done. +### : The 'set "P' -> 'set P' rewrite masks differences between whether Path +### : already contains a directory which needs escaping (e.g. building with +### : MSVC) +### opam env --shell=cmd | grep "PATH" | 'XXX:.*' -> '' | 'set "P' -> 'set P' +set "MANPATH=:"${BASEDIR}/OPAM/rewriting/man"" +set PATH=${BASEDIR}/OPAM/rewriting/bin;C:\Devel\bin1;C:\Devel\bin2;C:\Devel\bin3;C:\Devel\bin4;ZZZ:\; +### opam exec -- opam env --shell=cmd --revert | grep 'ZZZ:' | 'ZZZ:\\.*' -> 'ZZZ:\' | 'set "P' -> 'set P' ### : Test for #5838 ### opam env | grep MANPATH MANPATH=':"${BASEDIR}/OPAM/rewriting/man"'; export MANPATH; @@ -603,6 +628,7 @@ x-env-path-rewrite: [ [ RF_ENVSET_WITH_COL false ] [ RF_ENVSET_ADD false ] [ RF_ENVSET_ADD_WITH_COL false ] + [ PATH false ] [ RF_ENVBUILD false ] [ RF_ENVBUILD_STR false ]