pytorch/tools/code_coverage/package/tool/utils.py
Sam Estep 737d920b21 Strictly type everything in .github and tools (#59117)
Summary:
This PR greatly simplifies `mypy-strict.ini` by strictly typing everything in `.github` and `tools`, rather than picking and choosing only specific files in those two dirs. It also removes `warn_unused_ignores` from `mypy-strict.ini`, for reasons described in https://github.com/pytorch/pytorch/pull/56402#issuecomment-822743795: basically, that setting makes life more difficult depending on what libraries you have installed locally vs in CI (e.g. `ruamel`).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/59117

Test Plan:
```
flake8
mypy --config mypy-strict.ini
```

Reviewed By: malfet

Differential Revision: D28765386

Pulled By: samestep

fbshipit-source-id: 3e744e301c7a464f8a2a2428fcdbad534e231f2e
2021-06-07 14:49:36 -07:00

24 lines
758 B
Python

import subprocess
from ..util.setting import TestPlatform
from ..util.utils import print_error
def run_cpp_test(binary_file: str) -> None:
# cpp test binary
try:
subprocess.check_call(binary_file)
except subprocess.CalledProcessError:
print_error(f"Binary failed to run: {binary_file}")
def get_tool_path_by_platform(platform: TestPlatform) -> str:
if platform == TestPlatform.FBCODE:
from caffe2.fb.code_coverage.tool.package.fbcode.utils import get_llvm_tool_path # type: ignore[import]
return get_llvm_tool_path() # type: ignore[no-any-return]
else:
from ..oss.utils import get_llvm_tool_path # type: ignore[no-redef]
return get_llvm_tool_path() # type: ignore[no-any-return]