Coverage is incorrect for integration tests

オープン
#4,323 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Starlark
スター
857
フォーク
701
平均マージ
4日 7時間
マージ済み PR(30日)
46

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bazelbuild/rules_rust のほかの issue

bazelbuild/rules_rust の issue をすべて見る

似ている issue

Build System の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。