code: def main(argv):
      if len(argv) == 1:
          show_help()
          return
  
      build_isolation = None
      valgrind = False
      build_type = None
      implementations = None
      test_name = None
      venv_quick = False
      pytest_options = None
  
      args = iter(argv[1:])
      i = 0
      while 1:
          try:
              arg = next(args)
          except StopIteration:
              arg = None
              break
          if not arg.startswith("-"):
              break
          elif arg == "-b":
              build_type = next(args)
          elif arg == "--build-isolation":
              build_isolation = int(next(args))
          elif arg == "-d":
              build_type = "debug"
          elif arg in ("-h", "--help"):
              show_help()
              return
          elif arg == "-i":
              implementations = next(args)
          elif arg in ("--mupdf", "-m"):
              mupdf = next(args)
              if not mupdf.startswith("git:"):
                  assert os.path.isdir(
                      mupdf
                  ), f"Not a directory: {mupdf=}."
                  mupdf = os.path.abspath(mupdf)
              os.environ["PYMUPDF_SETUP_MUPDF_BUILD"] = mupdf
          elif arg == "-p":
              pytest_options = next(args)
          elif arg == "-t":
              test_name = next(args)
          elif arg == "-v":
              venv_quick = True
          elif arg == "--valgrind":
              valgrind = int(next(args))
          else:
              assert 0, f"Unrecognised option: {arg=}."
  
      if arg is None:
          log(f"No command specified.")
          return
  
      # We always want to run inside a venv.
      if sys.prefix == sys.base_prefix:
          # We are not running in a venv.
          log(f"Re-running in venv {gh_release.venv_name!r}.")
          gh_release.venv(["python"] + argv, quick=venv_quick)
          return
  
      def do_build():
          build(
              implementations=implementations,
              build_type=build_type,
              build_isolation=build_isolation,
              venv_quick=venv_quick,
          )
  
      def do_test():
          test(
              implementations=implementations,
              valgrind=valgrind,
              venv_quick=venv_quick,
              test_name=test_name,
              pytest_options=pytest_options,
          )
  
      while 1:
          if 0:
              pass
          elif arg == "build":
              do_build()
          elif arg == "test":
              do_test()
          elif arg == "buildtest":
              do_build()
              do_test()
          else:
              assert 0, f"Unrecognised command: {arg=}."
          try:
              arg = next(args)
          except StopIteration:
              break
  
file_path: pymudf/scripts/test.py
imports: import gh_release
  import os
  import platform
  import re
  import subprocess
  import sys
  import textwrap
label_desc: Use image node_id 1 for calling a global function with example usage: main(argv) without return types