File: persistent_tests.ml

package info (click to toggle)
ocaml-dune 3.20.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,564 kB
  • sloc: ml: 175,178; asm: 28,570; ansic: 5,251; sh: 1,096; lisp: 625; makefile: 148; python: 125; cpp: 48; javascript: 10
file content (58 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
open Stdune
module Persistent = Dune_util.Persistent
module Digest = Dune_digest

let test (type a) (module Persistent : Persistent.Desc with type t = a) (example : a) =
  let digest = Digest.generic example |> Digest.to_string in
  printfn "%s version %d\n%s\n---\n" Persistent.name Persistent.version digest
;;

let%expect_test "persistent digests" =
  Persistent.test_examples ()
  (* These digests are to make sure that we're bumping the version whenever we
     change the format of the values stored with [Persistent].

     The usual workflow goes something like this:

     1. The format of [Persistent.t] changes
     2. The new value is reflected by the value returned [test_example]
     3. The digest in this test suite changes and the test therefore fails

     To fix the test, the correct thing to do is to bump the appropriate
     version number where the persistent module is defined *)
  |> Stdlib.Seq.iter (fun (Persistent.T (desc, example)) -> test desc example);
  [%expect
    {|
    PROMOTED-TO-DELETE version 3
    65e543aaf5ccc8148d50a1305aa3622b
    ---

    DIGEST-DB version 7
    48031a13035ffa6b93b6b79ce277d39c
    ---

    INSTALL-COOKIE version 2
    da4ce847dd41df462849adecfe43f4eb
    ---

    TO-PROMOTE version 3
    f2d6070d92c27497a6c2d89782d81c99
    ---

    COPY-LINE-DIRECTIVE-MAP version 2
    72eb282c39bb084e69d6bd1615b8aaec
    ---

    CRAM-RESULT version 1
    65e543aaf5ccc8148d50a1305aa3622b
    ---

    merlin-conf version 7
    a14a4700929a15bb2030e36f71e66d20
    ---

    INCREMENTAL-DB version 6
    5d401c8cac2683cee736494457885f1f
    ---
    |}]
;;