pytorch/tools/code_coverage/package/tool/utils.py
yujunzhao@devvm1621.atn0.facebook.com da0e93a8c3 Move fbcode related coverage code to fb/ folder and add TARGETS (#43800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/43800

1. Move fbcode related coverage code to fb/ folder and add TARGETS so that we can use buck run to run the tool and solved the import probelm.

2. Write `README.md` to give users guidance about the tool

Test Plan:
On devserver:
```
buck run //caffe2/fb/code_coverage/tool:coverage -- //caffe2/c10:
```

More examples in README.md

Reviewed By: malfet

Differential Revision: D23404988

fbshipit-source-id: 4942cd0e0fb7bd28a5e884d9835b93f00adb7b92
2020-08-31 16:10:33 -07:00

24 lines
639 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):
if platform == TestPlatform.FBCODE:
from caffe2.fb.code_coverage.tool.package.fbcode.utils import get_llvm_tool_path
return get_llvm_tool_path()
else:
from ..oss.utils import get_llvm_tool_path
return get_llvm_tool_path()