aboutsummaryrefslogtreecommitdiff
path: root/test/test_config.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-21 12:19:43 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-21 12:19:43 +0200
commit055deaedd6bc1acb770bd96b7da8f985ab0f4f0b (patch)
tree6b453cd7a8fcaa7f8e4e257fa46c6a720778e8f4 /test/test_config.ml
parentaaf3dc5ba55d46b6b318bb761305013f4c533b26 (diff)
downloadcolitur-055deaedd6bc1acb770bd96b7da8f985ab0f4f0b.tar.gz
colitur-055deaedd6bc1acb770bd96b7da8f985ab0f4f0b.zip
feat(config): flavour is settable, and an INI overlay is diagnosed
The escaping flavour was the one rendering setting with no config key, so a template whose extension says nothing needed the flag every run. Unset still means infer, which config --show reports as (infer) rather than (none). Backfills the 0.8.0 and 0.9.0 changelog entries. Both were tagged by hand rather than through 'make release', which is precisely the guard that would have refused a release with no changelog line.
Diffstat (limited to 'test/test_config.ml')
-rw-r--r--test/test_config.ml19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_config.ml b/test/test_config.ml
index d348d9b..1dc1382 100644
--- a/test/test_config.ml
+++ b/test/test_config.ml
@@ -105,6 +105,23 @@ let test_two_defaults_blocks_report_no_unknown_sections () =
(* Task 8: sigla_style/sigla_book/sigla_tradition read the same way
lang/template/format do, in the same [\[defaults\]] section -- no new
section, and every key recognised (so [unknown_keys] stays empty). *)
+(* The escaping flavour is usually inferred from the template's extension, so
+ this key exists for the template whose extension says nothing. Getting it
+ wrong yields malformed output rather than ugly output, which is why there
+ is no silent fallback and why it is worth being settable rather than
+ passable only per-run. *)
+let test_flavour_is_read () =
+ match C.of_string "[defaults]\nflavour = groff\n" with
+ | Error e -> Alcotest.failf "parse: %s" e
+ | Ok c ->
+ Alcotest.(check (option string)) "flavour" (Some "groff") (C.flavour c);
+ Alcotest.(check (list string)) "nothing unknown" [] (C.unknown_keys c)
+
+let test_flavour_absent_is_none () =
+ match C.of_string "[defaults]\nlang = en\n" with
+ | Error e -> Alcotest.failf "parse: %s" e
+ | Ok c -> Alcotest.(check bool) "unset" true (C.flavour c = None)
+
let test_sigla_keys_are_read () =
let text =
"[defaults]\nsigla_style = la\nsigla_book = full\nsigla_tradition = modern\n"
@@ -149,6 +166,8 @@ let suite =
`Quick test_overlays_accumulate_across_blocks;
Alcotest.test_case "two defaults blocks report no unknown sections"
`Quick test_two_defaults_blocks_report_no_unknown_sections;
+ Alcotest.test_case "flavour is read" `Quick test_flavour_is_read;
+ Alcotest.test_case "flavour absent is none" `Quick test_flavour_absent_is_none;
Alcotest.test_case "sigla keys are read" `Quick test_sigla_keys_are_read;
Alcotest.test_case "empty config sigla keys are none" `Quick test_empty_config_sigla_keys_are_none;
Alcotest.test_case "sigla key repeated across blocks last wins"