From cfcc8721913a514eb152f39f431e86c5fec42bdb Mon Sep 17 00:00:00 2001 From: Lukasz Stafiniak Date: Wed, 20 Mar 2024 14:10:28 +0100 Subject: [PATCH] Test a flame graph example; fix previous commit test exp. --- test/debugger_sexp_html-toc.expected.html | 10 ++ test/test_debug_html.ml | 2 +- test/test_expect_test.ml | 107 ++++++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/test/debugger_sexp_html-toc.expected.html b/test/debugger_sexp_html-toc.expected.html index e69de29..a7c13f4 100644 --- a/test/debugger_sexp_html-toc.expected.html +++ b/test/debugger_sexp_html-toc.expected.html @@ -0,0 +1,10 @@ +
"test/test_debug_html.ml":9:19: foo
+ +
"test/test_debug_html.ml":17:19: bar
+ +
"test/test_debug_html.ml":23:19: baz
+ +
"test/test_debug_html.ml":30:19: lab
+ +
"test/test_debug_html.ml":36:24: loop
+ diff --git a/test/test_debug_html.ml b/test/test_debug_html.ml index 1ea906f..6911259 100644 --- a/test/test_debug_html.ml +++ b/test/test_debug_html.ml @@ -2,7 +2,7 @@ open Sexplib0.Sexp_conv module Debug_runtime = (val Minidebug_runtime.debug_file ~hyperlink:"../" ~toc_specific_hyperlink:"./" - ~with_table_of_contents:true + ~with_toc_listing:true ~backend:(`Html PrintBox_html.Config.(tree_summary true default)) "debugger_sexp_html") diff --git a/test/test_expect_test.ml b/test/test_expect_test.ml index 3dbfbb3..b6dbbcb 100644 --- a/test/test_expect_test.ml +++ b/test/test_expect_test.ml @@ -3554,3 +3554,110 @@ let%expect_test "%log_entry" = │ └─"log 4" └─"postscript" |}] + +let%expect_test "flame graph" = + let module Debug_runtime = + (val Minidebug_runtime.debug_file ~hyperlink:"../" ~toc_specific_hyperlink:"./" + ~toc_flame_graph:true + ~backend:(`Html PrintBox_html.Config.(tree_summary true default)) + "test_expect_test_flame_graph") + in + let%debug_show rec loop (depth : int) (x : t) : int = + if depth > 4 then x.first + x.second + else if depth > 1 then loop (depth + 1) { first = x.second + 1; second = x.first / 2 } + else + let y : int = loop (depth + 1) { first = x.second - 1; second = x.first + 2 } in + let z : int = loop (depth + 1) { first = x.second + 1; second = y } in + z + 7 + in + let () = ignore @@ loop 0 { first = 7; second = 42 } in + let file = open_in "test_expect_test_flame_graph-toc.html" in + (try + while true do + print_endline @@ input_line file + done + with End_of_file -> ()); + close_in file; + let output = [%expect.output] in + let output = + Str.global_replace + (Str.regexp + {|[0-9]+\.[0-9][0-9][0-9]+|}) + "N.NNNN" output + in + print_endline output; + [%expect {| +
+
+
+
+
+
+
+
|}]