Skip to content

Commit

Permalink
Merge pull request #166 from OpenDevin/xw/attempt-fix-django-parsing
Browse files Browse the repository at this point in the history
Fix newline outputs for django's log parser
  • Loading branch information
john-b-yang authored Jul 2, 2024
2 parents 3d57d51 + c61bc10 commit fd13837
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions swebench/harness/log_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@ def parse_log_django(log: str) -> dict[str, str]:
"""
test_status_map = {}
lines = log.split("\n")

prev_test = None
for line in lines:
line = line.strip()

# This isn't ideal but the test output spans multiple lines
if "--version is equivalent to version" in line:
test_status_map["--version is equivalent to version"] = TestStatus.PASSED.value

# Log it in case of error
if " ... " in line:
prev_test = line.split(" ... ")[0]

pass_suffixes = (" ... ok", " ... OK", " ... OK")
for suffix in pass_suffixes:
if line.endswith(suffix):
Expand Down Expand Up @@ -107,6 +113,12 @@ def parse_log_django(log: str) -> dict[str, str]:
test = line.split()[1].strip()
test_status_map[test] = TestStatus.ERROR.value

if line.lstrip().startswith("ok") and prev_test is not None:
# It means the test passed, but there's some additional output (including new lines)
# between "..." and "ok" message
test = prev_test
test_status_map[test] = TestStatus.PASSED.value

# TODO: This is very brittle, we should do better
# There's a bug in the django logger, such that sometimes a test output near the end gets
# interrupted by a particular long multiline print statement.
Expand Down

0 comments on commit fd13837

Please sign in to comment.