diff --git a/README.md b/README.md index 4266f70..0a6c828 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,13 @@ The json must have the following fields: if multiple files are to be skipped, they must be separated with `|`). It should be used to exclude autogenerated files. If the repository does not have any autogenerated files, `exclude_path` should be an empty string. -- `crate_features`: `cargo kcov` does not build crate features by default. To - get the coverage report including optional features, these need to be - specified in `crate_features` separated by comma. If the crate does not have - any features, this field should be empty. + +Additionally, the following optional fields are available: + +- `crate_features`: By default, we pass `--all-features` to cargo when collecting + coverage. To have the coverage report only include a subset of features (in addition + to default features, which are always enabled), specify them in this field + as a comma-separated string. This file is required for the coverage integration so it needs to be added to the repository as well. 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.