MCPcopy Create free account
hub / github.com/OSGeo/PROJ / main

Function main

test/cli/run_cli_test.py:906–940  ·  view source on GitHub ↗
(filename, exe=None, env=None, exitfirst=False, update=False, verbose=1)

Source from the content-addressed store, hash-verified

904
905
906def main(filename, exe=None, env=None, exitfirst=False, update=False, verbose=1):
907 tester = Tester.from_yaml(filename, update=update, verbose=verbose)
908 if exe is not None:
909 tester.exe = exe
910 glob_env = os.environ.copy()
911 # Add/update PWD, which may be out-of-sync
912 glob_env["PWD"] = str(Path.cwd())
913 glob_env.update(tester.env)
914 if env is not None:
915 glob_env.update(env)
916 if verbose:
917 print("Relevant environment variables:")
918 for key, value in glob_env.items():
919 if key.startswith("PROJ") or "NABLED" in key:
920 print(f" {key}={value}")
921 # Check exe
922 exe_path = Path(tester.exe)
923 full_exe_path = str(exe_path)
924 if exe_path.is_dir():
925 raise FileNotFoundError(f"'{exe_path}' is a directory, not a path to an EXE")
926 elif tester.exe[1:3] == ":/":
927 # CMake passes paths with forward slashes, which breaks D:/path/to/invproj.exe
928 if full_exe_path[1:3] == ":/": # on MSYS2 force to :\
929 full_exe_path = full_exe_path.replace("/", "\\")
930 tester.exe = full_exe_path
931 elif exe_path.is_absolute():
932 if not exe_path.exists():
933 raise FileNotFoundError(f"cannot find '{tester.exe}' (does not exist)")
934 else:
935 full_exe_path = shutil.which(tester.exe)
936 if full_exe_path is None:
937 raise FileNotFoundError(f"cannot find '{tester.exe}' (not found on PATH)")
938 if verbose:
939 print(f"Testing '{full_exe_path}'")
940 return tester.run(glob_env, exitfirst=exitfirst)
941
942
943if __name__ == "__main__":

Callers 1

run_cli_test.pyFile · 0.70

Calls 4

printFunction · 0.85
from_yamlMethod · 0.80
existsMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected