Skip to content

Commit e184399

Browse files
committed
coverage: make crate_features key optional
Currently, if a crate wishes to run the coverage test with some cargo features enabled, it must explicitly list them out in the `crate_features` key of the coverage json files. Change this so that if this key is omitted from the json file, then test_coverage.py passes `--all-features` to cargo. No functional change, as currently `crate_features` is a mandatory key, so to opt-in to this new behavior, crates must remove this key from their coverage json file(s). Signed-off-by: Patrick Roy <[email protected]>
1 parent 8ae03e5 commit e184399

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

integration_tests/test_coverage.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def _read_test_config():
4949

5050
assert "coverage_score" in coverage_config
5151
assert "exclude_path" in coverage_config
52-
assert "crate_features" in coverage_config
5352

54-
assert (
55-
" " not in coverage_config["crate_features"]
56-
), "spaces are not allowed in crate_features value"
53+
if "crate_features" in coverage_config:
54+
assert (
55+
" " not in coverage_config["crate_features"]
56+
), "spaces are not allowed in crate_features value"
5757

5858
return coverage_config
5959

@@ -87,9 +87,11 @@ def _get_current_coverage(coverage_config, no_cleanup, test_scope):
8787
if test_scope == pytest.workspace:
8888
llvm_cov_command += " --workspace "
8989

90-
crate_features = coverage_config["crate_features"]
90+
crate_features = coverage_config.get("crate_features")
9191
if crate_features:
9292
llvm_cov_command += " --features=" + crate_features
93+
if crate_features is None:
94+
llvm_cov_command += " --all-features"
9395

9496
# Pytest closes stdin by default, but some tests might need it to be open.
9597
# In the future, should the need arise, we can feed custom data to stdin.

0 commit comments

Comments
 (0)