From 6a9baeb505567297d2c0f6ff8fb9d86a0665a0e5 Mon Sep 17 00:00:00 2001 From: Bernhard Kaindl Date: Wed, 20 Mar 2024 12:00:00 +0100 Subject: [PATCH] CA-390127: Fix adding even the last log() messages to the output archive 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 27a9866..b4fbc56 100755 --- a/xen-bugtool +++ b/xen-bugtool @@ -1278,8 +1278,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): @@ -1316,6 +1314,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)