old_contents: import os
  import sys
  import shlex
  from subprocess import Popen, PIPE
  import argparse
  
  TEST_CASE_DIRECTORY = "./cases"
  
  def get_exitcode_stdout_stderr(cmd):
      """
      Executes an external command and returns the exitcode, stdout and stderr.
      """
      args = shlex.split(cmd)
  
      proc = Popen(args, stdout=PIPE, stderr=PIPE)
      out, err = proc.communicate()
      exitcode = proc.returncode
      
      return exitcode, out, err
  
  parser = argparse.ArgumentParser(description="Regression testing.")
  parser.add_argument(dest="operation", choices=["test", "rebase"])
  parser.add_argument(dest="zydis_info_path", type=str)
  args = parser.parse_args()
  
  has_failed = False
  
  for case in os.listdir(TEST_CASE_DIRECTORY):
      if case.endswith(".in"):
          path = os.path.join(TEST_CASE_DIRECTORY, case)
          print(path)
  
          with open(path, mode="r") as f: 
              payload = f.read()
  
          exitcode, out, err = get_exitcode_stdout_stderr(f"{args.zydis_info_path} {payload}")
  
          pre, ext = os.path.splitext(case)
          path = os.path.join(TEST_CASE_DIRECTORY, pre + ".out")
  
          if args.operation == "rebase":
              with open(path, mode="wb") as f:
                  f.write(out)
              continue
  
          try:
              with open(path, mode="rb") as f:
                  s = f.read()
  
              if s != out:
                  print(f"FAILED: '{case}' [{payload}]")
                  has_failed = True
          except:
              print(f"FAILED: '{case}' [Output file missing]")
              has_failed = True
  
  sys.exit(-1 if has_failed else 0)
new_contents: import os
  import sys
  import shlex
  from subprocess import Popen, PIPE
  import argparse
  
  TEST_CASE_DIRECTORY = "./cases"
  
  def get_exitcode_stdout_stderr(cmd):
      """
      Executes an external command and returns the exitcode, stdout and stderr.
      """
      args = shlex.split(cmd)
  
      proc = Popen(args, stdout=PIPE, stderr=PIPE)
      out, err = proc.communicate()
      exitcode = proc.returncode
      
      return exitcode, out, err
  
  parser = argparse.ArgumentParser(description="Regression testing.")
  parser.add_argument(dest="operation", choices=["test", "rebase"])
  parser.add_argument(dest="zydis_info_path", type=str)
  args = parser.parse_args()
  
  has_failed = False
  
  for case in os.listdir(TEST_CASE_DIRECTORY):
      if not case.endswith(".in"):
          continue
  
      path = os.path.join(TEST_CASE_DIRECTORY, case)
      print(path)
  
      with open(path, mode="r") as f: 
          payload = f.read()
  
      exitcode, out, err = get_exitcode_stdout_stderr(f"{args.zydis_info_path} {payload}")
  
      pre, ext = os.path.splitext(case)
      path = os.path.join(TEST_CASE_DIRECTORY, pre + ".out")
  
      if args.operation == "rebase":
          with open(path, mode="wb") as f:
              f.write(out)
          continue
  
      try:
          with open(path, mode="rb") as f:
              s = f.read()
  
          if s != out:
              print(f"FAILED: '{case}' [{payload}]")
              has_failed = True
      except FileNotFoundError:
          print(f"FAILED: '{case}' [Output file missing]")
          has_failed = True
  
  sys.exit(-1 if has_failed else 0)
subject: Resolve PR comments