Coverage is incorrect for integration tests

Aperta
#4,323 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Starlark
Stelle
857
Fork
701
Merge medio
4g 7h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/rules_rust

Tutte le issue di bazelbuild/rules_rust

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.