Coverage is incorrect for integration tests

Abierto
#4,323 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

Start from collect_coverage, which passes only the test binary to llvm-cov export, and check how the library's object file could be added via the -object flag. Reproduce with a rust_library of only generic functions, a rust_test that uses it through deps and calls one function, then run bazel coverage --instrument_test_targets. Done when the uncalled generic function appears as uncovered in the report.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs-triage

Description

When a rust_test depends on a library through deps instead of crate, uncalled generic functions are missing from the coverage report instead of showing as uncovered.

rustc emits coverage records for those functions into the library’s own object file. If the test doesn’t reference any symbol in that object, the linker never pulls it out of the rlib, and the records are lost. A library made entirely of generics reports 100% coverage no matter what the tests do.

collect_coverage currently gives llvm-cov export only the test binary, so it never sees those records. They’re still in the library’s compiled object file, though, and llvm-cov export can read additional files through its -object flag.

Reproduction steps
To reproduce, create a rust_library that contains only generic functions, and a rust_test that depends on it through deps and calls just one of them. Running bazel coverage --instrument_test_targets on the test reports 100% coverage for the library, and the uncalled function is missing from the report.

Impact
Coverage reports are broken for integration tests.

Bazel and rules_rust version
Tested on Bazel 9.2.0 and rules_rust 0.74.0

Lenguaje dominante
Starlark
Estrellas
857
Forks
701
Merge medio
4 d 7 h
PR fusionados (30 d)
46

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bazelbuild/rules_rust

Todos los issues de bazelbuild/rules_rust

Issues similares

Más issues de Build System

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.