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 all commits
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
7 changes: 5 additions & 2 deletions rere.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
# 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

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

def read_blob_field(f: BinaryIO, name: bytes) -> bytes:
line = f.readline()
field = b':b ' + name + b' '
Expand Down Expand Up @@ -52,7 +55,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,
Expand Down Expand Up @@ -135,7 +138,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")
Expand Down