From df7ee9f1e57f347c6cc499b58c02822d383f2cdf Mon Sep 17 00:00:00 2001 From: Ali Caglayan Date: Mon, 2 Oct 2023 18:35:21 +0100 Subject: [PATCH] test(pkg): more extensive env update tests (#8788) Signed-off-by: Ali Caglayan --- .../test-cases/pkg/opam-package-with-setenv.t | 69 ++++++++++++++++--- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t index b6d3c48c1d0..232f90a4470 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t @@ -26,11 +26,7 @@ Make another package that depends on that and outputs the exported env vars > [ "sh" "-c" "echo $append_with_leading_sep" ] > ] > EOF - - $ mkdir -p $mock_packages/with-setenv/with-setenv.0.0.1 - $ mkdir -p $mock_packages/deps-on-with-setenv/deps-on-with-setenv.0.0.1 - - $ solve_project < solve_project < (lang dune 3.8) > (package > (name x) @@ -68,14 +64,65 @@ The exported env from the first package should be in the lock dir. When building the second package the exported env vars from the first package should be available and all the env updates should be applied correctly. +$ EXPORTED_ENV_VAR="I have not been exported yet." \ +> prepend_without_trailing_sep="foo:bar" \ +> prepend_with_trailing_sep="foo:bar" \ +> append_without_leading_sep="foo:bar" \ +> append_with_leading_sep="foo:bar" \ +> build_pkg deps-on-with-setenv + +We now make a third package that updates the env in a similar way, in order to see the +difference between a propagated export_env versus the initial env. + + $ mkpkg with-setenv-2 < depends: [ "with-setenv" ] + > setenv: [ + > [EXPORTED_ENV_VAR = "Hello from the second package!"] + > [prepend_with_trailing_sep := "Prepended 2nd time with sep"] + > [prepend_without_trailing_sep += "Prepended 2nd time without trailing sep"] + > [append_without_leading_sep =+ "Appended 2nd time without leading sep"] + > [append_with_leading_sep =: "Appended 2nd time with leading sep"] + > ] + > EOF + > mkpkg deps-on-with-setenv-2 <<'EOF' + > depends: [ "with-setenv-2" ] + > build: [ + > [ "sh" "-c" "echo $EXPORTED_ENV_VAR" ] + > [ "sh" "-c" "echo $prepend_without_trailing_sep" ] + > [ "sh" "-c" "echo $prepend_with_trailing_sep" ] + > [ "sh" "-c" "echo $append_without_leading_sep" ] + > [ "sh" "-c" "echo $append_with_leading_sep" ] + > ] + > EOF + > solve_project < (lang dune 3.8) + > (package + > (name x) + > (allow_empty) + > (depends deps-on-with-setenv-2)) + > EOF + Solution for dune.lock: + deps-on-with-setenv-2.0.0.1 + with-setenv.0.0.1 + with-setenv-2.0.0.1 + +We can now observe how the environment updates are applied a second time. + +We currently have the following issues: +- The leading and traling seperators are missing. +- The initial enviornment is missing. + + $ EXPORTED_ENV_VAR="I have not been exported yet." \ > prepend_without_trailing_sep="foo:bar" \ > prepend_with_trailing_sep="foo:bar" \ > append_without_leading_sep="foo:bar" \ > append_with_leading_sep="foo:bar" \ - > build_pkg deps-on-with-setenv - Hello from the other package! - Prepended without trailing sep - Prepended with trailing sep - Appended without leading sep - Appended with leading sep + > build_pkg deps-on-with-setenv-2 + Hello from the second package! + Prepended 2nd time without trailing sep:Prepended without trailing sep + Prepended 2nd time with sep:Prepended with trailing sep + Appended without leading sep:Appended 2nd time without leading sep + Appended with leading sep:Appended 2nd time with leading sep + +