diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py index 68f2efdfa5a..3c53c440d47 100755 --- a/.gitlab-ci/lava/lava_job_submitter.py +++ b/.gitlab-ci/lava/lava_job_submitter.py @@ -375,10 +375,12 @@ def fix_lava_color_log(line): """This function is a temporary solution for the color escape codes mangling problem. There is some problem in message passing between the LAVA dispatcher and the device under test (DUT). Here \x1b character is missing - before `[:digit::digit:?m` ANSI TTY color codes. When this problem is fixed - on the LAVA side, one should remove this function. + before `[:digit::digit:?:digit:?m` ANSI TTY color codes, or the more + complicated ones with number values for text format before background and + foreground colors. + When this problem is fixed on the LAVA side, one should remove this function. """ - line["msg"] = re.sub(r"(\[\d{1,2}m)", "\x1b" + r"\1", line["msg"]) + line["msg"] = re.sub(r"(\[(\d+;){0,2}\d{1,3}m)", "\x1b" + r"\1", line["msg"]) def fix_lava_gitlab_section_log(line): diff --git a/.gitlab-ci/tests/test_lava_job_submitter.py b/.gitlab-ci/tests/test_lava_job_submitter.py index 975b1939ff2..def946c1ac9 100644 --- a/.gitlab-ci/tests/test_lava_job_submitter.py +++ b/.gitlab-ci/tests/test_lava_job_submitter.py @@ -364,6 +364,24 @@ COLOR_MANGLED_SCENARIOS = { ), "\x1b[0mPass: 26718, ExpectedFail: 95, Skip: 25187, Duration: 8:18, Remaining: 13", ), + "Mangled error message with bold formatting at target level": ( + create_lava_yaml_msg(msg="[1;31mReview the image changes...", lvl="target"), + "\x1b[1;31mReview the image changes...", + ), + "Mangled error message with high intensity background at target level": ( + create_lava_yaml_msg(msg="[100mReview the image changes...", lvl="target"), + "\x1b[100mReview the image changes...", + ), + "Mangled error message with underline+bg color+fg color at target level": ( + create_lava_yaml_msg(msg="[4;41;97mReview the image changes...", lvl="target"), + "\x1b[4;41;97mReview the image changes...", + ), + "Bad input for color code.": ( + create_lava_yaml_msg( + msg="[4;97 This message is missing the `m`.", lvl="target" + ), + "[4;97 This message is missing the `m`.", + ), }