Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to reversal of environment updates #5935

Merged
merged 18 commits into from
May 15, 2024
Merged

Commits on May 15, 2024

  1. reftests: add sort command

    Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
    dra27 and rjbou committed May 15, 2024
    Configuration menu
    Copy the full SHA
    c4750ce View commit details
    Browse the repository at this point in the history
  2. reftests: sort 'opam env' output for stability

    opam env itself makes no guarantee of the ordering
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    13ebdea View commit details
    Browse the repository at this point in the history
  3. Add test for updates with mixed slashes

    CAML_LD_LIBRARY_PATH should appear in opam env --revert
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    199a4b7 View commit details
    Browse the repository at this point in the history
  4. Add test for ocaml#5838

    MANPATH should appear in opam env --revert
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    f16bbc1 View commit details
    Browse the repository at this point in the history
  5. Add regression test for ocaml#4861

    As in this commit, there should be no output captured from the
    opam env --revert invocation.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    7e7388c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    81220db View commit details
    Browse the repository at this point in the history
  7. Add test for ocaml#5925

    NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    cd3ffad View commit details
    Browse the repository at this point in the history
  8. Add test for ocaml#5926

    - In `opam exec -- env` / `opam env`:
      - NV_VARS_5926_L_2 should be `b::a` (the _L_1 case is correct)
      - NV_VARS_5926_L_4 should be `:a:b` (the _L_3 case is correct)
      - NV_VARS_5926_L_5 and _L_6 should be `b::a` (neither is correct)
      - NV_VARS_5926_L_8 should be `:a:b` (the _L_7 case is correct)
      - All four NV_VARS_5926_M_ all contain `a1:a2` instead of `a1::a2`
      - NV_VARS_5926_T_2 should be `:b:a` (the _T_1 case is correct)
      - NV_VARS_5926_T_4 should be `a::b` (the _T_3 case is correct)
      - NV_VARS_5926_T_6 should be `:b:a` (the _T_5 case is correct)
      - NV_VARS_5926_T_7 and _T_8 should be `a::b` (neither is correct)
    - In `opam exec -- opam env --revert`:
      - NV_VARS_5926_L_{2,4,6,8} revert to `a` instead of `:a`
      - NV_VARS_5926_M_{1,2,3,4} should all revert to `a1::a2` where
        - _M_1 and _M_3 only have a single colon (`a1:a2`)
        - _M_2 and _M_4 have reversed the two components! (`a2:a1`)
      - NV_VARS_5926_T_{2,4,6,8} revert to `a` instead of `a:`
      - Note NV_VARS_5926_S_{1,2,3,4} revert to empty rather than `:`
        (this is correct since both interpretations are equivalent and
        opam can't know which it was)
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    86b31b6 View commit details
    Browse the repository at this point in the history
  9. Transform arguments before reversing an env_update

    Missing transformation of the argument, which affected reverting updates
    with forward slashes (e.g. "%{lib}%/stublibs")
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    3228abb View commit details
    Browse the repository at this point in the history
  10. OpamEnv.split_var: use correct split functions

    The cases of this match were the wrong way around.
    
    Note that this regresses ocaml#4861's quoted directory test.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    ba9cd26 View commit details
    Browse the repository at this point in the history
  11. Expose the Win32 logic in OpamStd.Sys.split_path

    Expose a generalised version of the Windows implementation of
    PATH-splitting as OpamStd.String.split_quoted.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    d1a8017 View commit details
    Browse the repository at this point in the history
  12. Replace PATH-splitting implementation in OpamEnv

    Existing implementation was not correct w.r.t. separators which were
    themselves quoted. Use OpamStd.String.split_quoted instead. However,
    this causes superfluous quotes in variables to be removed.
    
    Note that this fixes the MANPATH issue of ocaml#5838 but the quoting-handling
    is still broken.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    9380e5d View commit details
    Browse the repository at this point in the history
  13. Fix appending to empty env vars (ocaml#5925)

    Ensure that if opam has internally synthesised an empty environment
    variable, then adding to it doesn't create a stray colon.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    4eb951d View commit details
    Browse the repository at this point in the history
  14. Preserve quoting in environment variables

    Change the internal representation of environment variables so that both
    the original quoted version and the parsed version are kept, along with
    the separator. This has the benefit that reconstituting the variable
    value does not require knowledge of the separator (which deals
    coherently with the parasitic case of two packages updating the same
    variable with a different separator: the value is almost certainly
    trashed, but it is at least trashed in a semantically coherent manner!)
    
    Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
    dra27 and rjbou committed May 15, 2024
    Configuration menu
    Copy the full SHA
    5db5951 View commit details
    Browse the repository at this point in the history
  15. Correct value-splitting w.r.t. x-env-path-rewrite

    When reverting [FOO += "value"], it is necessary to determine what to do
    if "value" is of the form "<value1><sep><value2>". Because FOO itself
    will have been split at <sep>, we will never match
    "<value1><sep><value2>" so it is necessary to split value at <sep> as
    well (this is the crux of ocaml#4861).
    
    However, the interaction of this and x-env-path-rewrite is incorrect. If
    x-env-path-rewrite has [FOO false] (the `norewrite case), then the value
    must be split according to the default interpretation of FOO (which is
    how it was added).
    
    If x-env-path-rewrite has a rewrite rule for FOO, then opam has already
    assumed that value refers to a single directory (the host/target and
    quoting transformation options all being this way).
    
    If x-env-path-rewrite does not have any rule (and does have have
    [FOO false]) then we are in essence in the backwards-compatible case,
    and must split value.
    
    In order to stop poor interaction between this and opam itself
    injecting Windows paths, opam's updates in OpamEnv (to MANPATH, etc.)
    are explicitly expanded so that in unzip_to they are treated as though
    they had an x-env-path-rewrite rule given (and are therefore not split).
    
    Combined with the previous fixes, this addresses ocaml#5838 without
    regressing ocaml#4861.
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    57a7b83 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    20a64c9 View commit details
    Browse the repository at this point in the history
  17. Rework logic of := and =: operators (ocaml#5926)

    := and =: now ensure that an empty directory empty is always introduced
    then all the append operators ensure that an empty directory entry is
    maintained (see env.test changes).
    dra27 committed May 15, 2024
    Configuration menu
    Copy the full SHA
    9046905 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    eeba7d2 View commit details
    Browse the repository at this point in the history