From 6f2026e84b86c6081de6c284f117c9523804f472 Mon Sep 17 00:00:00 2001 From: Noah Watson Date: Tue, 9 Jul 2024 13:53:56 -0500 Subject: [PATCH] Store requests sequence in JSON format as well in bug reports --- pyk/src/pyk/kore/rpc.py | 7 ++++--- pyk/src/pyk/utils.py | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pyk/src/pyk/kore/rpc.py b/pyk/src/pyk/kore/rpc.py index 24cfde7a76e..e4d7f9213c8 100644 --- a/pyk/src/pyk/kore/rpc.py +++ b/pyk/src/pyk/kore/rpc.py @@ -71,7 +71,7 @@ def request(self, req: str, request_id: int, method_name: str) -> str: if self._bug_report: bug_report_request = f'{req_name}_request.json' self._bug_report.add_file_contents(req, Path(bug_report_request)) - self._bug_report.add_command(self._command(req_name, bug_report_request)) + self._bug_report.add_request_command(req_name, self._command(req_name, bug_report_request)) server_addr = self._description() _LOGGER.info(f'Sending request to {server_addr}: {request_id} - {method_name}') @@ -83,14 +83,15 @@ def request(self, req: str, request_id: int, method_name: str) -> str: if self._bug_report: bug_report_response = f'{req_name}_response.json' self._bug_report.add_file_contents(resp, Path(bug_report_response)) - self._bug_report.add_command( + self._bug_report.add_request_command( + req_name, [ 'diff', '-b', '-s', f'{req_name}_actual.json', f'{req_name}_response.json', - ] + ], ) return resp diff --git a/pyk/src/pyk/utils.py b/pyk/src/pyk/utils.py index 15d4c9665ec..26c5bb74dec 100644 --- a/pyk/src/pyk/utils.py +++ b/pyk/src/pyk/utils.py @@ -1,6 +1,7 @@ from __future__ import annotations import hashlib +import json import logging import os import shlex @@ -665,12 +666,14 @@ class BugReport: _command_id: int _defn_id: int _file_remap: dict[str, str] + _requests_sequence: dict[int, str] def __init__(self, bug_report: Path) -> None: self._bug_report = bug_report.with_suffix('.tar') self._command_id = 0 self._defn_id = 0 self._file_remap = {} + self._requests_sequence = {} if self._bug_report.exists(): _LOGGER.warning(f'Bug report exists, removing: {self._bug_report}') self._bug_report.unlink() @@ -688,6 +691,11 @@ def add_file_contents(self, input: str, arcname: Path) -> None: ntf.flush() self.add_file(Path(ntf.name), arcname) + def add_request_command(self, req_name: str, args: Iterable[str]) -> None: + self._requests_sequence[self._command_id] = req_name + self.add_file_contents(json.dumps(self._requests_sequence), Path('requests_sequence.json')) + self.add_command(args) + def add_command(self, args: Iterable[str]) -> None: def _remap_arg(_a: str) -> str: if _a in self._file_remap: