From 74eea8fe332c05774f108c5094eb335e58f44cfa Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 14 Oct 2022 13:43:32 +0300 Subject: Fix printing test id multiple times on test failure --- libbuild2/test/script/runner.cxx | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'libbuild2/test/script/runner.cxx') diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx index 340ada4..98d6868 100644 --- a/libbuild2/test/script/runner.cxx +++ b/libbuild2/test/script/runner.cxx @@ -166,18 +166,24 @@ namespace build2 text << ": " << c << expr; } - // Print test id once per test expression. + // Print test id once per test expression and only for the topmost + // one. // auto df = make_diag_frame ( - [&sp](const diag_record& dr) + [&sp, print = (sp.exec_level == 0)](const diag_record& dr) { - // Let's not depend on how the path representation can be improved - // for readability on printing. - // - dr << info << "test id: " << sp.id_path.posix_string (); + if (print) + { + // Let's not depend on how the path representation can be + // improved for readability on printing. + // + dr << info << "test id: " << sp.id_path.posix_string (); + } }); + ++sp.exec_level; build2::script::run (sp, expr, ii, li, ll, cf); + --sp.exec_level; } bool default_runner:: @@ -189,18 +195,26 @@ namespace build2 if (verb >= 3) text << ": ?" << expr; - // Print test id once per test expression. + // Print test id once per test expression and only for the topmost + // one. // auto df = make_diag_frame ( - [&sp](const diag_record& dr) + [&sp, print = (sp.exec_level == 0)](const diag_record& dr) { - // Let's not depend on how the path representation can be improved - // for readability on printing. - // - dr << info << "test id: " << sp.id_path.posix_string (); + if (print) + { + // Let's not depend on how the path representation can be + // improved for readability on printing. + // + dr << info << "test id: " << sp.id_path.posix_string (); + } }); - return build2::script::run_cond (sp, expr, ii, li, ll); + ++sp.exec_level; + bool r (build2::script::run_cond (sp, expr, ii, li, ll)); + --sp.exec_level; + + return r; } } } -- cgit v1.1