Skip to content

Scope is evaluated in the exec configuration: platform select()s resolve for the host, not the target #23

Closed

Description

@dcalavrezo-qorix

Found by @4og reviewing eclipse-score/baselibs#626 (QNX on-target coverage): the QNX report lists score/os/linux/* at 0 % and contains no file from score/os/qnx/.

Cause

Bazel attaches --coverage_report_generator to test rules through BaseRuleClasses.coverageReportGeneratorAttribute with ExecutionTransitionFactory (StarlarkRuleClassFunctions.java), so the score_coverage_reporter target and its coverage_scope dependency are analysed in the exec configuration. The scope aspect therefore resolves every select() for the host platform (Linux), whatever --platforms the coverage run uses. Consequences on a QNX run:

  • libraries selected for QNX ("@platforms//os:qnx": [...]) are not in the allowlist and never appear, not even as no-data;
  • their Linux counterparts are in the allowlist and show 0 % from the gcno/object baseline (compiled for the host);
  • the allowlist is identical for the Linux and the QNX run (978 files in baselibs for both).

The shared, platform-independent code (the vast majority) is measured correctly; the per-test data comes from the real QNX run.

Proposal

Give the scope an explicit target platform: an optional platform label attribute on score_coverage_scope (or on score_coverage_reporter, forwarded) whose transition sets //command_line_option:platforms next to collect_code_coverage, so the aspect, the baseline objects and the gcno notes are those of the target platform. Consumers then declare one scope per platform and use select() for platform-only roots (an incompatible root fails analysis). Verify with a fixture in the integration workspace whose select() differs between host and target platform, document in the manual (step 4b), add a potential error and a requirement, release as 0.4.0.

Until then: known problem in the manual; QNX reports are valid for platform-independent code and wrong for platform-specific files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions