Skip to content

Commit 8311e08

Browse files
author
Diptorup Deb
committed
Improvements to gen_coverage.py helper script.
-- Add an option to specify custom gtest installation. -- FindLLVMCov offers a way to specify where to look for llvm-cov. If `bin-llvm` is provided, set the `LLVM_TOOL_DIR` envar as well to help FindLLVMCov. Otherwise, just adding to PATH is not enough. -- Some formatting fixes to coverage workflow.
1 parent acb158e commit 8311e08

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.github/workflows/generate-coverage.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ jobs:
8787
source /opt/intel/oneapi/setvars.sh
8888
export _SAVED_PATH=${PATH}
8989
export PATH=$(dirname $(dirname $(which icx)))/bin-llvm:${PATH}
90-
python setup.py develop -- -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx -DDPCTL_ENABLE_LO_PROGRAM_CREATION=ON -DDPCTL_GENERATE_COVERAGE=ON -DDPCTL_BUILD_CAPI_TESTS=ON -DDPCTL_COVERAGE_REPORT_OUTPUT_DIR=$(pwd)
90+
python setup.py develop -- \
91+
-G "Ninja" \
92+
-DCMAKE_BUILD_TYPE=Debug \
93+
-DCMAKE_C_COMPILER:PATH=icx \
94+
-DCMAKE_CXX_COMPILER:PATH=icpx \
95+
-DDPCTL_ENABLE_LO_PROGRAM_CREATION=ON \
96+
-DDPCTL_GENERATE_COVERAGE=ON \
97+
-DDPCTL_BUILD_CAPI_TESTS=ON \
98+
-DDPCTL_COVERAGE_REPORT_OUTPUT_DIR=$(pwd)
9199
pushd $(find _skbuild -name tests)
92100
cmake --build . --target lcov-genhtml || exit 1
93101
popd

scripts/gen_coverage.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def run(
2727
compiler_root=None,
2828
run_pytest=False,
2929
bin_llvm=None,
30+
gtest_config=None,
3031
):
3132
IS_LIN = False
3233

@@ -66,18 +67,14 @@ def run(
6667
if bin_llvm:
6768
env = {
6869
"PATH": ":".join((os.environ.get("PATH", ""), bin_llvm)),
70+
"LLVM_TOOLS_HOME": bin_llvm,
6971
}
7072
env.update({k: v for k, v in os.environ.items() if k != "PATH"})
73+
if gtest_config:
74+
cmake_args += ["-DCMAKE_PREFIX_PATH=" + gtest_config]
7175
subprocess.check_call(cmake_args, shell=False, cwd=setup_dir, env=env)
72-
test_dir = (
73-
subprocess.check_output(
74-
["find", "_skbuild", "-name", "tests"], cwd=setup_dir
75-
)
76-
.decode("utf-8")
77-
.strip("\n")
78-
)
7976
subprocess.check_call(
80-
["make", "-C", test_dir, "lcov-genhtml"], cwd=setup_dir
77+
["cmake", "--build", ".", "--target", "lcov-genhtml"], cwd=setup_dir
8178
)
8279
subprocess.check_call(
8380
[
@@ -135,6 +132,11 @@ def run(
135132
driver.add_argument(
136133
"--bin-llvm", help="Path to folder where llvm-cov can be found"
137134
)
135+
driver.add_argument(
136+
"--gtest-config",
137+
help="Path to the GTestConfig.cmake file to locate a "
138+
+ "custom GTest installation.",
139+
)
138140
args = parser.parse_args()
139141

140142
if args.oneapi:
@@ -170,4 +172,5 @@ def run(
170172
compiler_root=args.compiler_root,
171173
run_pytest=args.run_pytest,
172174
bin_llvm=args.bin_llvm,
175+
gtest_config=args.gtest_config,
173176
)

0 commit comments

Comments
 (0)