Module Vcs_test_helpers

Helper library to write tests using vcs.

type 'a env = 'a constraint 'a = < fs : [> Eio.Fs.dir_ty ] Eio.Path.t ; process_mgr : [> [> `Generic ] Eio.Process.mgr_ty ] Eio.Resource.t.. >
val init_temp_repo : env:_ env -> sw:Eio.Switch.t -> vcs:[> Vcs.Trait.config | Vcs.Trait.init ] Vcs.t -> Vcs.Repo_root.t

Create a fresh temporary directory and initiate a repo in it. The switch provided is used to attach a task that will discard the repo when the switch is released.

val redact_sexp : Base.Sexp.t -> fields:Base.string Base.list -> Base.Sexp.t

This helper allows to filter out unstable and brittle parts of errors before printing them in an expect test trace. The fields parameter specifies which field-paths to redact.

In its most simple form, a field may simply be a field name that will end up being redacted. For example, if the error is:

((field_a ...)
 (field_b <UNSTABLE>))

then the fields parameter should be ["field_b"], and in this case, redact_sexp error ~fields:["field_b"] will result in:

((field_a ...)
 (field_b <REDACTED>))

Some form of nesting is supported for convenience: in case you only want to redact a field if it is nested deep into another field. In this case, the syntax is to use a "/" separator in the field. For example, if the error is:

((steps ((Vcs.init ((path /invalid/path)))))
 (error (
   (prog git)
   (args (init .))
   (exit_status Unknown)
   (cwd         /invalid/path)
   (stdout      "")
   (stderr      "")
   (error       <UNSTABLE>))))

then the fields parameter should be ["error/error"]. You may mix nested and non-nested fields in the same fields list.