Skip to content

Commit

Permalink
Merge pull request #6233 from rjbou/reftest-cache
Browse files Browse the repository at this point in the history
Reftest: add `opam-cache` printing command
  • Loading branch information
kit-ty-kate authored Oct 10, 2024
2 parents 787553c + 859aa8d commit e563a67
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 19 deletions.
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ users)
* pin: add a test for erroneous first fetch done as local path on local VCS pinned packages [#6221 @rjbou]

### Engine
* Update print file function [#6233 @rjbou]
* Add `opam-cache` command, to display internal cache content in reftest [#6233 @rjbou]

## Github Actions
* Add OCaml 5.2.0 to the build matrix [#6216 @kit-ty-kate]
Expand All @@ -134,6 +136,7 @@ users)
## opam-repository

## opam-state
* `OpamSwitchState.Installed_cache`: export `load` function [#6233 @rjbou]

## opam-solver

Expand Down
1 change: 1 addition & 0 deletions src/state/opamSwitchState.mli
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ val avoid_version : 'a switch_state -> package -> bool
(** Handle a cache of the opam files of installed packages *)
module Installed_cache: sig
type t = OpamFile.OPAM.t OpamPackage.Map.t
val load: OpamFilename.t -> t option
val save: OpamFilename.t -> t -> unit
val remove: OpamFilename.t -> unit
end
2 changes: 1 addition & 1 deletion tests/reftests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

(executable
(name run)
(libraries opam-core re opam-file-format)
(libraries opam-core re opam-file-format opam-state)
(modules run))

(executable
Expand Down
5 changes: 5 additions & 0 deletions tests/reftests/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ output...
* `json-cat file`: print a human readable opam output json file, with
replacement of some duration and temporary files names. meant to be used
on opam generated json files.
* `opam-cache installed <switch> [nvs]`: print the content of installed
packages cache for switch `<switch>`. If `[nvs]` is specified, filter over
these package names or packages.
* `opam-cache repo [nvs]`: print the content of repository cache. If
`[nvs]` is specified, filter over these package names or packages.

- if you need more shell power, create a script using <FILENAME> then run it.
Or just use `sh -c`... but beware for compatibility.
Expand Down
146 changes: 146 additions & 0 deletions tests/reftests/reftests.test
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,149 @@ Done.
}
]
}
### :V:3: Cache cat
### <OPER/repo>
opam-version: "2.0"
### <OPER/packages/foo/foo.2/opam>
opam-version: "2.0"
### <OPER/packages/un/un.2/opam>
opam-version: "2.0"
### <OPER/packages/deux/deux.2/opam>
opam-version: "2.0"
### opam switch create cache --empty
### opam repository add oper ./OPER
[oper] Initialised
[NOTE] Repository oper has been added to the selections of switch cache only.
Run `opam repository add oper --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

### opam install bar baz foo un deux
The following actions will be performed:
=== install 5 packages
- install bar 1
- install baz 1
- install deux 2
- install foo 2
- install un 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed bar.1
-> installed baz.1
-> installed deux.2
-> installed foo.2
-> installed un.2
Done.
### :V:3: installed packages cache
### opam-cache installed cache
=> un.2 <=
opam-version: "2.0"
name: "un"
version: "2"
=> foo.2 <=
opam-version: "2.0"
name: "foo"
version: "2"
=> deux.2 <=
opam-version: "2.0"
name: "deux"
version: "2"
=> baz.1 <=
opam-version: "2.0"
name: "baz"
version: "1"
extra-files: ["xf-baz" "md5=9ac116bceba2bdf45065df19d26a6b64"]
=> bar.1 <=
opam-version: "2.0"
name: "bar"
version: "1"
extra-files: ["xf-bar" "md5=dbaf1ea561686374373dc7d154f3a0ff"]
### opam-cache installed cache foo
=> foo.2 <=
opam-version: "2.0"
name: "foo"
version: "2"
### opam-cache installed cache foo un
=> un.2 <=
opam-version: "2.0"
name: "un"
version: "2"
=> foo.2 <=
opam-version: "2.0"
name: "foo"
version: "2"
### opam-cache installed cache inexistent
### opam switch create cache2 --empty
### opam-cache installed cache2
Empty cache
### opam-cache installed cache2 foo
Empty cache
### opam-cache installed cache3
No cache
### :V:3:b: repo cache
### opam-cache repo
=> oper:un.2 <=
opam-version: "2.0"
name: "un"
version: "2"
=> oper:foo.2 <=
opam-version: "2.0"
name: "foo"
version: "2"
=> oper:deux.2 <=
opam-version: "2.0"
name: "deux"
version: "2"
=> default:qux.1 <=
opam-version: "2.0"
name: "qux"
version: "1"
extra-files: ["xf-qux" "md5=ccacf3e9d1e3f473e093042aa309e9da"]
=> default:grault.1 <=
opam-version: "2.0"
name: "grault"
version: "1"
extra-files: [
["file" "md5=00000000000000000000000000000000"]
["xf-grault" "md5=9fd8d4d58e5fd899478b03ab24a11d00"]
["xf-grault2" "md5=5c1ff559ac6490338d362978c058f44a"]
]
=> default:foo.1 <=
opam-version: "2.0"
name: "foo"
version: "1"
extra-files: ["xfile" "md5=f343d90d29f2632b7e5fcf8ee249d1b5"]
=> default:corge.1 <=
opam-version: "2.0"
name: "corge"
version: "1"
extra-files: ["xf-corge" "md5=71e14bfb95ec10cb60f3b6cafd908a08"]
=> default:baz.1 <=
opam-version: "2.0"
name: "baz"
version: "1"
extra-files: ["xf-baz" "md5=9ac116bceba2bdf45065df19d26a6b64"]
=> default:bar.1 <=
opam-version: "2.0"
name: "bar"
version: "1"
extra-files: ["xf-bar" "md5=dbaf1ea561686374373dc7d154f3a0ff"]
### opam-cache repo foo
=> oper:foo.2 <=
opam-version: "2.0"
name: "foo"
version: "2"
=> default:foo.1 <=
opam-version: "2.0"
name: "foo"
version: "1"
extra-files: ["xfile" "md5=f343d90d29f2632b7e5fcf8ee249d1b5"]
### opam-cache repo un baz
=> oper:un.2 <=
opam-version: "2.0"
name: "un"
version: "2"
=> default:baz.1 <=
opam-version: "2.0"
name: "baz"
version: "1"
extra-files: ["xf-baz" "md5=9ac116bceba2bdf45065df19d26a6b64"]
### opam-cache repo inexistent
Loading

0 comments on commit e563a67

Please sign in to comment.