Skip to content

Commit

Permalink
Better fix for wrong line numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Sep 20, 2023
1 parent 77afb43 commit e470f3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
8 changes: 0 additions & 8 deletions tested/languages/javascript/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ def cleanup_stacktrace(self, traceback: str) -> str:
compilation_submission_location = str(submission_location.resolve())
execution_location_regex = f"{self.config.dodona.workdir}/{EXECUTION_PREFIX}[_0-9]+/{EXECUTION_PREFIX}[_0-9]+.js"
submission_namespace = f"{submission_name(self)}."
location_pattern = r"(\d+):(\d+)"

def update_line_number(match: re.Match) -> str:
assert self.config
return f"{int(match.group(1)) + self.config.dodona.source_offset}:{match.group(2)}"

resulting_lines = ""
for line in traceback.splitlines(keepends=True):
Expand All @@ -183,9 +178,6 @@ def update_line_number(match: re.Match) -> str:
# Remove any references of the form "submission.SOMETHING"
line = line.replace(submission_namespace, "")

# Adjust line numbers
line = re.sub(location_pattern, update_line_number, line)

resulting_lines += line

return resulting_lines
Expand Down
5 changes: 2 additions & 3 deletions tested/oracles/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
_logger = logging.getLogger(__name__)


def try_as_exception(config: OracleConfig, value: str) -> ExceptionValue:
def try_as_exception(value: str) -> ExceptionValue:
actual = get_converter().loads(value, ExceptionValue)
actual.stacktrace = config.bundle.language.cleanup_stacktrace(actual.stacktrace)
return actual


Expand Down Expand Up @@ -62,7 +61,7 @@ def evaluate(
)

try:
actual = try_as_exception(config, actual_str)
actual = try_as_exception(actual_str)
except Exception as e:
_logger.exception(e)
staff_message = ExtendedMessage(
Expand Down

0 comments on commit e470f3e

Please sign in to comment.