blob: 31d49eb0c5dfa1eabad44469cf14509a2a982c55 (
plain) (
blame)
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
|
(* SPDX-License-Identifier: AGPL-3.0-or-later *)
(* Every citation the engine can emit must parse. This is the check that
would have caught the seven duplicate book spellings -- nothing validated
them before.
Same shape as test_lang_coverage.ml, which this file deliberately mirrors:
a miss there is a slug with no name, a miss here is a citation the parser
cannot read. *)
module P = Colitur_citation.Parse
let test_every_citation_parses () =
let layer =
match Test_support.load_ef_layer () with
| Ok l -> l
| Error e -> Alcotest.failf "%s" e
in
let ctx = Test_support.ef_context () in
let bad = Hashtbl.create 64 in
for y = 1970 to 2070 do
Array.iter
(fun (d : (Rite_ef.Vocab_ef.season, Rite_ef.Vocab_ef.rank) Colitur_kernel.Liturgical_day.t) ->
List.iter
(fun (c : Colitur_kernel.Citation.t) ->
let r = c.Colitur_kernel.Citation.reference in
match P.parse r with
| Ok _ -> ()
| Error e -> if not (Hashtbl.mem bad r) then Hashtbl.add bad r e)
d.Colitur_kernel.Liturgical_day.citations)
(Colitur_kernel.Calendar.year ctx layer y)
done;
if Hashtbl.length bad > 0 then begin
Hashtbl.iter (fun r e -> Printf.eprintf "UNPARSED %S: %s\n" r e) bad;
Alcotest.failf "%d citation(s) did not parse" (Hashtbl.length bad)
end
(* This project has ONE test executable. Every test_<module>.ml exposes a
[suite] value and test_colitur.ml aggregates them -- do NOT call
Alcotest.run here. Marked `Slow like test_lang_coverage's own year walk. *)
let suite =
( "citation-coverage",
[ Alcotest.test_case "every citation parses" `Slow test_every_citation_parses ] )
|