Skip to content

Commit 0d97543

Browse files
committed
fix: expand regex matching for js runtime flags
1 parent 7383dbb commit 0d97543

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/bugmon/bug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def runtime_opts(self) -> List[str]:
330330
for flag in all_flags:
331331
if flag in self.comment_zero:
332332
match = re.search(
333-
rf"(--{flag}[a-z0-9=-]*)", self.comment_zero, re.IGNORECASE
333+
rf"(--{flag}[a-z0-9=\-_]*)", self.comment_zero, re.IGNORECASE
334334
)
335335
if match is not None:
336336
flags.append(match.group(0))

tests/test_bug.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,42 @@ def test_bug_assignee(bug_data, has_assignee):
326326
assert bug.assignee == data[f"{expected}_detail"]
327327

328328

329+
@pytest.mark.parametrize(
330+
"flag, suffix",
331+
[
332+
("spectre-mitigations", ""), # no value
333+
("baseline-warmup-threshold", "=1000"), # digits
334+
("ion-regalloc", "=backtracking"), # letters
335+
("ion-regalloc", "=lsra-backtracking"), # hyphen
336+
("baseline-warmup-threshold", "=1_000"), # underscore
337+
("ion-regalloc", "=back_tracking-v2"), # mixed
338+
],
339+
)
340+
def test_bug_runtime_opts(mocker, bug_data, flag, suffix):
341+
"""Test that runtime_opts correctly parses runtime flags"""
342+
data = copy.deepcopy(bug_data)
343+
data["comments"][0]["text"] = f"--{flag}{suffix}"
344+
bug = EnhancedBug(bugsy=None, **data)
345+
bug._initial_build_id = "72f0cfd2cd42"
346+
347+
mocker.patch("bugmon.bug.JSEvaluator.get_valid_flags", return_value=[flag])
348+
349+
assert bug.runtime_opts == [f"--{flag}{suffix}"]
350+
351+
352+
def test_bug_runtime_opts_not_present(mocker, bug_data):
353+
"""Test that runtime_opts returns empty list when flag is absent"""
354+
bug = EnhancedBug(bugsy=None, **bug_data)
355+
bug._initial_build_id = "72f0cfd2cd42"
356+
357+
mocker.patch(
358+
"bugmon.bug.JSEvaluator.get_valid_flags",
359+
return_value=["baseline-warmup-threshold"],
360+
)
361+
362+
assert bug.runtime_opts == []
363+
364+
329365
def test_bug_add_needinfo(bug_data):
330366
"""Test that needinfo can be added to a bug"""
331367
data = copy.deepcopy(bug_data)

0 commit comments

Comments
 (0)