From 54f5cdf48b45e607eeadeaffa12b30b58fc18b80 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Wed, 13 Oct 2021 12:11:04 +0200 Subject: [PATCH] ENH: Better test output formatting. --- test/Run_Test.m | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/test/Run_Test.m b/test/Run_Test.m index 340a7fc..de45573 100644 --- a/test/Run_Test.m +++ b/test/Run_Test.m @@ -18,11 +18,45 @@ pkg load caosdb; -all_tests = true; -all_tests &= moxunit_runtests("-verbose", "test_query_retrieve.m"); -all_tests &= moxunit_runtests("-verbose", "test_transaction.m"); -all_tests &= moxunit_runtests("-verbose", "test_files.m"); +tests = struct("name", {"test_query_retrieve.m", ... + "test_transaction.m", ... + "test_files.m"} ... + ); -if not(all_tests) +for i = [1:numel(tests)] + result = moxunit_runtests("-verbose", tests(i).name); + tests(i).result = result; +end +result_all = all([tests.result]); + +max_width = max(cellfun(@numel, {tests.name})) + 2; +max_width -= mod(max_width, -4); % round to next largest multiple of 4. + +disp("\n===========================\n"); +disp("Result of integration tests"); +disp("===========================\n"); +for i = [1:numel(tests)] + result_str = "FAIL"; + if tests(i).result + result_str = "PASS"; + end + disp(sprintf(["%-" num2str(max_width) "s %s"], tests(i).name, result_str)); +end +disp(repmat("-", [1, max_width + 4 + numel(result_str)])); + +passes = sum([tests.result]); +fails = sum(~[tests.result]); +passes_str = sprintf("%d passed", passes); +fails_str = sprintf("%d failed", fails); + +result_str = "FAIL"; +if result_all > 0 + result_str = "PASS"; +end + +result_str = sprintf("%s (%s, %s)", result_str, passes_str, fails_str); +disp(result_str); + +if not(result_all) exit(1); end -- GitLab