Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve compatibility
- Make compatible with Windows and Python <3.9
  • Loading branch information
realshouzy committed Jun 2, 2024
commit 4904d1de7abdb5b2c459c049343f6b2bdc839732
10 changes: 8 additions & 2 deletions rere.py
Original file line number Diff line number Diff line change
@@ -19,12 +19,18 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import annotations

import sys
import subprocess
from difflib import unified_diff
from typing import List, BinaryIO, Tuple, Optional

if sys.platform == "win32":
SHELL_COMMAND = ('cmd', '/c')
else:
SHELL_COMMAND = ('sh', '-c')

def read_blob_field(f: BinaryIO, name: bytes) -> bytes:
line = f.readline()
field = b':b ' + name + b' '
@@ -52,7 +58,7 @@ def write_blob_field(f: BinaryIO, name: bytes, blob: bytes):

def capture(shell: str) -> dict:
print(f"CAPTURING: {shell}")
process = subprocess.run(['sh', '-c', shell], capture_output = True)
process = subprocess.run([*SHELL_COMMAND, shell], capture_output = True)
return {
'shell': shell,
'returncode': process.returncode,
@@ -135,7 +141,7 @@ def load_snapshots(file_path: str) -> list[dict]:
print(f" ACTUAL: {shell}")
print(f"NOTE: You may want to do `{program_name} record {test_list_path}` to update {test_list_path}.bi")
exit(1)
process = subprocess.run(['sh', '-c', shell], capture_output = True);
process = subprocess.run([*SHELL_COMMAND, shell], capture_output = True);
failed = False
if process.returncode != snapshot['returncode']:
print(f"UNEXPECTED: return code")