From 60c73a56ec964305ccae9fb5610c7799b0ee3ca7 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Thu, 21 Mar 2024 17:54:07 +0100 Subject: [PATCH] CA-390127: Fix adding even the last log() messages to the output archive (#93) Signed-off-by: Bernhard Kaindl --- tests/unit/test_main.py | 11 +++-------- xen-bugtool | 8 ++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 49b77cb..5787432 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -245,14 +245,9 @@ def assert_bugtool_logfile_data(logfile): # caught and logged, the log file should contain the backtrace from the # raised exception: # - # FIXME: This is not working in Python 2.7 yet (in this specific case): CA-390127 - # CA-390127 affects Python3 in principle too, but it does not make this test fail - # Fixing CA-390127 is a prerequisite for enabling this check for Python 2.7: - # - if sys.version_info.major > 2: # pragma: no cover - assert len(lines) == 9 - for backtrace_string in MOCK_EXCEPTION_STRINGS: - assert backtrace_string in log + assert len(lines) == 9 + for backtrace_string in MOCK_EXCEPTION_STRINGS: + assert backtrace_string in log def assert_valid_inventory(bugtool, args, cap, tmp_path, base_path, filetype): diff --git a/xen-bugtool b/xen-bugtool index 55e7228..62cfb6b 100755 --- a/xen-bugtool +++ b/xen-bugtool @@ -1274,8 +1274,6 @@ exclude those logs from the archive. cmd_output(CAP_YUM, [RPM, '-qa']) tree_output(CAP_YUM, SIGNING_KEY_INFO_DIR) - file_output(CAP_XEN_BUGTOOL, [XEN_BUGTOOL_LOG]) - # permit the user to filter out data for k in sorted(data.keys()): if not ANSWER_YES_TO_ALL and not yes("Include '%s'? [Y/n]: " % k): @@ -1312,6 +1310,12 @@ exclude those logs from the archive. output_ts('Running commands to collect data') collect_data(subdir, archive) + # after all is done, include all log() entries from the XEN_BUGTOOL_LOG file + if CAP_XEN_BUGTOOL in entries: + archive.addRealFile( + construct_filename(subdir, XEN_BUGTOOL_LOG, {}), XEN_BUGTOOL_LOG + ) + # include inventory include_inventory(archive, subdir)