From e94bff4ff5082eeeb2f558f4b8e069690fc9f35e Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Mon, 17 Mar 2025 10:52:21 +0000 Subject: [PATCH] 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 --- integration_tests/test_coverage.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/integration_tests/test_coverage.py b/integration_tests/test_coverage.py index 39b66a8..9a9d83f 100644 --- a/integration_tests/test_coverage.py +++ b/integration_tests/test_coverage.py @@ -49,11 +49,11 @@ def _read_test_config(): assert "coverage_score" in coverage_config assert "exclude_path" in coverage_config - assert "crate_features" in coverage_config - assert ( - " " not in coverage_config["crate_features"] - ), "spaces are not allowed in crate_features value" + if "crate_features" in coverage_config: + assert ( + " " not in coverage_config["crate_features"] + ), "spaces are not allowed in crate_features value" return coverage_config @@ -87,9 +87,11 @@ def _get_current_coverage(coverage_config, no_cleanup, test_scope): if test_scope == pytest.workspace: llvm_cov_command += " --workspace " - crate_features = coverage_config["crate_features"] + crate_features = coverage_config.get("crate_features") if crate_features: llvm_cov_command += " --features=" + crate_features + if crate_features is None: + llvm_cov_command += " --all-features" # Pytest closes stdin by default, but some tests might need it to be open. # In the future, should the need arise, we can feed custom data to stdin.