Skip to content

Commit

Permalink
test(pkg): more extensive env update tests (#8788)
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Caglayan <alizter@gmail.com>
  • Loading branch information
Alizter authored Oct 2, 2023
1 parent 9cf1e0a commit df7ee9f
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
> solve_project <<EOF
> (lang dune 3.8)
> (package
> (name x)
Expand Down Expand Up @@ -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 <<EOF
> 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 <<EOF
> (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


0 comments on commit df7ee9f

Please sign in to comment.