diff --git a/tests/common.ml b/tests/common.ml
new file mode 100644
index 00000000..af8f2abc
--- /dev/null
+++ b/tests/common.ml
@@ -0,0 +1,4 @@
+let normalize_html s =
+ String.trim s
+ |> Soup.parse
+ |> Soup.pretty_print
diff --git a/tests/dune b/tests/dune
index f8f6743d..6478096a 100644
--- a/tests/dune
+++ b/tests/dune
@@ -1,8 +1,14 @@
(executable
(name extract_tests)
- (libraries str lambdasoup)
+ (libraries str common)
(modules extract_tests))
+; Code shared between various parts of the testing apartus
+(library
+ (name common)
+ (libraries lambdasoup)
+ (modules common))
+
; Generate and run tests for the core omd package
(rule
(with-stdout-to
@@ -16,7 +22,7 @@
(executable
(name omd)
- (libraries str omd omd_tyxml tyxml lambdasoup)
+ (libraries str omd omd_tyxml tyxml common)
(modules omd))
; Generate the rules for diff-based tests
diff --git a/tests/extract_tests.ml b/tests/extract_tests.ml
index 4a377bed..886eef00 100644
--- a/tests/extract_tests.ml
+++ b/tests/extract_tests.ml
@@ -2,26 +2,26 @@
let disabled =
[
- 164;
- 175;
- 184;
- 185;
- 334;
- 353;
- 410;
- 411;
- 414;
- 415;
- 416;
- 428;
- 468;
- 469;
- 486;
- 516;
- 536;
- 570;
- 519;
- 591;
+ (* 164;
+ * 175;
+ * 184;
+ * 185;
+ * 334;
+ * 353;
+ * 410;
+ * 411;
+ * 414;
+ * 415;
+ * 416;
+ * 428;
+ * 468;
+ * 469;
+ * 486;
+ * 516;
+ * 536;
+ * 570;
+ * 519;
+ * 591; *)
]
let with_open_in fn f =
@@ -75,7 +75,7 @@ let parse_test_spec filename =
let rec get_html () =
let line = input_line ic in
if begins_with line test_delim then
- let html = Buffer.contents buf in
+ let html = Buffer.contents buf |> Common.normalize_html in
{filename; example; markdown; html}
else begin
add_line buf line;
@@ -117,18 +117,13 @@ let write_dune_file test_specs tests =
"@[
", "
\n"
- (* ; Str.regexp_string ">\n\n", ">\n" *)
- (* ; Str.regexp "\n\n$", "\n" *)
- (* Str.regexp "\"/>", "\" />"
- * ; Str.regexp_string "
", "
\n"
- * ; Str.regexp_string "", "
\n"
- * ; Str.regexp_string "
", "
" - * ; Str.regexp_string "
\nList.map (fun b -> b |> Omd_tyxml.of_block |> tyxml_elt_to_string) |> String.concat "" -let normalize_html s = Soup.(parse s |> pretty_print) - let denormalize_html str = List.fold_left (fun s (re, rep) -> Str.global_replace re rep s) str replacements @@ -49,6 +27,6 @@ let () = ic |> Omd.of_channel |> html_of_omd - |> normalize_html + |> Common.normalize_html |> denormalize_html |> print_string