Skip to content

Commit

Permalink
Make opam config report and opam switch set-invariant return the actu…
Browse files Browse the repository at this point in the history
…al invariant syntax expected by --invariant
  • Loading branch information
kit-ty-kate committed Jul 26, 2023
1 parent 445b377 commit 6dce83c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ let config cli =
print "current-switch" "%s"
(OpamSwitch.to_string state.switch);
print "invariant" "%s"
(OpamFormula.to_string state.switch_invariant);
(OpamFileTools.dep_formula_to_string state.switch_invariant);
print "compiler-packages" "%s"
(let packages = OpamSwitchState.compiler_packages state in
if OpamPackage.Set.is_empty packages then "none" else
Expand Down Expand Up @@ -3026,7 +3026,7 @@ let switch cli =
in
let st = OpamSwitchCommand.set_invariant ~force st invariant in
OpamConsole.msg "The switch invariant was set to %s\n"
(OpamFormula.to_string invariant);
(OpamFileTools.dep_formula_to_string invariant);
let st =
if no_action || OpamFormula.satisfies_depends st.installed invariant
then OpamSwitchAction.update_switch_state st
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/cli-versioning.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Added 'cli: "version"' to field variables in switch cli-versioning
[WARNING] OPAMNODEPEXTS was ignored because CLI 2.0 was requested and it was introduced in 2.1.
Added 'cli: "version"' to field variables in switch cli-versioning
### OPAMSHOW=0 opam switch set-invariant baz.1 --no-action
The switch invariant was set to baz = 1
The switch invariant was set to ["baz" {= "1"}]
### OPAMCLI=2.0 opam install baz.2
[WARNING] OPAMNODEPEXTS was ignored because CLI 2.0 was requested and it was introduced in 2.1.
[ERROR] Package conflict!
Expand Down
6 changes: 3 additions & 3 deletions tests/reftests/config.test
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Done.
# repositories 2 (local)
# pinned 1 (rsync)
# current-switch a-switch
# invariant meta-compiler = 1
# invariant ["meta-compiler" {= "1"}]
# compiler-packages compiler.1, dep-compiler.1
# meta-compiler:compvar something
### opam repository remove second --all
Expand Down Expand Up @@ -183,7 +183,7 @@ Done.
# repositories 1 (local)
# pinned 0
# current-switch a-package-invariant
# invariant a-package
# invariant ["a-package"]
# compiler-packages compiler.1, dep-compiler.1
# meta-compiler:compvar something
### # compiler with depopt
Expand Down Expand Up @@ -211,6 +211,6 @@ Done.
# repositories 1 (local)
# pinned 0
# current-switch a-compiler-with-depopt
# invariant meta-compiler & depopt-compiler
# invariant ["meta-compiler" "depopt-compiler"]
# compiler-packages compiler.1, dep-compiler.1, depopt-compiler.1
# meta-compiler:compvar something
2 changes: 1 addition & 1 deletion tests/reftests/list.test
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ abt
No solution found, exiting
# Return code 20 #
### opam switch set-invariant --formula '["ocaml" {>= "4.01.0"}]' --no-action
The switch invariant was set to ocaml >= 4.01.0
The switch invariant was set to ["ocaml" {>= "4.01.0"}]
### opam list ab* -s --installable
abella
absolute
Expand Down
10 changes: 5 additions & 5 deletions tests/reftests/switch-invariant.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ opam-version: "2.0"
[non-default] no changes from file://${BASEDIR}/repo2
### opam switch create inv --empty --repo=default,non-default
### opam switch set-invariant foo
The switch invariant was set to foo
The switch invariant was set to ["foo"]
The following actions will be performed:
=== install 1 package
- install foo 1
Expand All @@ -24,11 +24,11 @@ The following actions will be performed:
-> installed foo.1
Done.
### opam switch set-invariant foo
The switch invariant was set to foo
The switch invariant was set to ["foo"]
### opam switch set-invariant --package foo
The switch invariant was set to foo
The switch invariant was set to ["foo"]
### opam switch set-invariant bar
The switch invariant was set to bar
The switch invariant was set to ["bar"]
The following actions will be performed:
=== install 1 package
- install bar 1
Expand All @@ -37,7 +37,7 @@ The following actions will be performed:
-> installed bar.1
Done.
### opam switch set-invariant --package bar
The switch invariant was set to bar
The switch invariant was set to ["bar"]
### <pkg:bar.1>
opam-version: "2.0"
### <pkg:bar.2>
Expand Down
4 changes: 2 additions & 2 deletions tests/reftests/switch-list.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following actions will be performed:
-> installed g.1
Done.
### opam switch set-invariant b
The switch invariant was set to b
The switch invariant was set to ["b"]
### opam switch list
# switch compiler description
-> display a.1 display
Expand Down Expand Up @@ -113,7 +113,7 @@ The following actions will be performed:
-> installed g.1
Done.
### opam switch set-invariant b
The switch invariant was set to b
The switch invariant was set to ["b"]
The following actions will be performed:
=== install 1 package
- install b 1
Expand Down

0 comments on commit 6dce83c

Please sign in to comment.