Skip to content

Commit

Permalink
Store requests sequence in JSON format as well in bug reports
Browse files Browse the repository at this point in the history
  • Loading branch information
nwatson22 committed Jul 9, 2024
1 parent f6d64e9 commit 6f2026e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pyk/src/pyk/kore/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions pyk/src/pyk/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import hashlib
import json
import logging
import os
import shlex
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand Down

0 comments on commit 6f2026e

Please sign in to comment.