Skip to content

Compiled doctests omit dependency runtime data and include the compiler SDK in runfiles #4289

Description

@jrandolf

Description

With experimental_compile_rustdoc_tests enabled, a doctest can compile but fail when it reads a file declared in its crate's data or a dependency's runfiles. The compiled-doctest rule uses the compilation action's inputs as test runfiles instead of merging the runtime files from the crate and its dependencies. The same choice also includes the compiler SDK in the test inputs.

The test should receive its declared runtime files and required native shared libraries. Compiler tools belong to the compilation action.

Reproduction steps

The fixture in #4272 reads files from the crate, a transitive dependency and an explicit doctest dependency. It also reads compile_data and calls a shared native library, so changing the runfiles construction cannot drop those inputs.

Add the fixture directory to the affected revision, leaving the production rules unchanged, then run on macOS with a nightly toolchain:

bazel test --config=nightly \
  --//rust/settings:experimental_compile_rustdoc_tests=true \
  //test/rustdoc_runfiles:runtime_data_test \
  //test/rustdoc_runfiles:compiled_runfiles_test

The runtime test should read all three data files. The analysis test should find those files in runfiles and the compiler SDK only in the compilation inputs. Before the fix, the data is missing and the SDK is a test input.

Additional context

Proposed fix: #4272. It merges the existing crate/dependency runfiles and retains native shared libraries from CcInfo, including resolved symlink targets.

This report concerns propagation of existing runtime dependencies in compiled mode. #1317 tracks a data attribute on rust_doc_test. The native fixture uses a runfiles-relative install name/SONAME to keep this regression focused on file propagation.

Impact

Data-reading compiled doctests fail at runtime, and their test inputs include an unnecessary compiler SDK.

Bazel and rules_rust version

Affected rules_rust revision: c708b236. The existing regression work used Bazel 9.2.0 on macOS arm64.
Compiled-doctest cases use the nightly channel. The existing runtime regression ran on macOS; Windows execution is outside that fixture.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions