Skip to content

Commit 09ca1d1

Browse files
committed
Refactor checking for substring in output
1 parent abd75e5 commit 09ca1d1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/lithium/interestingness/outputs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ def interesting(
7272
run_info = timed_run(args.cmd_with_flags, args.timeout, temp_prefix)
7373

7474
if temp_prefix is None:
75-
outputs = (run_info.out, run_info.err)
76-
for data in outputs:
77-
if (args.regex and re.match(args.search, data, flags=re.MULTILINE)) or (
78-
args.search.encode("utf-8") in data
79-
):
75+
encoded = args.search.encode("utf-8")
76+
match = encoded if args.regex else re.escape(encoded)
77+
for data in (run_info.out, run_info.err):
78+
if re.search(match, data, flags=re.MULTILINE):
8079
LOG.info("[Interesting] Match detected!")
8180
return True
8281

0 commit comments

Comments
 (0)