From 1ea28f27e3c3ddfed352ec1d2941ac8ff9623117 Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Thu, 4 Sep 2025 13:20:19 +0530 Subject: [PATCH 1/3] Trim system_out logs to last 1000 words in junit-xml --- opl/junit_cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opl/junit_cli.py b/opl/junit_cli.py index 5b6ffd6..25c7596 100755 --- a/opl/junit_cli.py +++ b/opl/junit_cli.py @@ -62,6 +62,13 @@ def _remove_control_characters(self, s): return "".join( ch for ch in s if unicodedata.category(ch)[0] != "C" or ch == "\n" ) + def trim_string_fn(self, data, trim_length): + matches = list(re.finditer(r'\S+', data)) + if len(matches) <= trim_length: + return data + # Get the start index of the Nth-to-last word + start_index = matches[-trim_length].start() + return data[start_index:] def add_to_suite(self, suite_name, new): case = TestCaseWithProp(new["name"]) @@ -102,6 +109,7 @@ def add_to_suite(self, suite_name, new): except ValueError as e: logging.error(f"Failed to load {new['system-err'].name} file: {e}") + case.system_out= self.trim_string_fn(case.system_out,1000) duration = (new["end"] - new["start"]).total_seconds() case.time = duration From bd3a8a59f446fd194f3575996979f38252c6245f Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Fri, 5 Sep 2025 11:13:28 +0530 Subject: [PATCH 2/3] fix linting issues --- opl/junit_cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opl/junit_cli.py b/opl/junit_cli.py index 25c7596..263000a 100755 --- a/opl/junit_cli.py +++ b/opl/junit_cli.py @@ -62,8 +62,9 @@ def _remove_control_characters(self, s): return "".join( ch for ch in s if unicodedata.category(ch)[0] != "C" or ch == "\n" ) + def trim_string_fn(self, data, trim_length): - matches = list(re.finditer(r'\S+', data)) + matches = list(re.finditer(r"\S+", data)) if len(matches) <= trim_length: return data # Get the start index of the Nth-to-last word @@ -109,7 +110,7 @@ def add_to_suite(self, suite_name, new): except ValueError as e: logging.error(f"Failed to load {new['system-err'].name} file: {e}") - case.system_out= self.trim_string_fn(case.system_out,1000) + case.system_out = self.trim_string_fn(case.system_out, 1000) duration = (new["end"] - new["start"]).total_seconds() case.time = duration From ef7450d836cffa9059329b07888cad5ae02d5a3c Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Fri, 5 Sep 2025 12:05:14 +0530 Subject: [PATCH 3/3] import re command added --- opl/junit_cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opl/junit_cli.py b/opl/junit_cli.py index 263000a..570555d 100755 --- a/opl/junit_cli.py +++ b/opl/junit_cli.py @@ -6,6 +6,7 @@ import unicodedata import junitparser import urllib3 +import re import requests