No coverage files generated outside project on Julia 1.9

I am working with two packages, where a downstream package depends on a base package. The directory structure is of the form

A
  - Project.toml
  - Manifest.toml
  - src
    - [...]
  - test
    - [...]
  - B
    - Project.toml
    - Manifest.toml
    - src
      - [...]
    - test
      - [...]

Other unrelated files are not mentioned here.

The downstream package B devs the base package A. I am trying to run the tests for B and look at the coverage in A/src, that is how much of A’s code is covered by the testset of B.

I am using

julia --startup=no --project=downstream --code-coverage=user

to start Julia, and then I use

julia> using Pkg

julia> Pkg.test(coverage=true)

to run the tests for B on Julia v1.9.3. The tests run fine, but I find that *.cov files are generated only within B/src. No *.cov files are generated in A/src. The behavior is as expected on Julia v1.6, where running the tests generates a *.cov corresponding to each source file in A/src that is hit. I’m unsure why this is not the case on v1.9. I have also tried with --code-coverage=all but that doesn’t change anything, as might be expected. The tests on v1.9 do hit these files, but there’s no corresponding coverage file that’s written out.

In Julia 1.9 Highlights there’s a mention of coverage tracking fewer files by default, but I couldn’t understand if this changes the behavior of --code-coverage=user.

Any suggestion on how to restore the 1.6-like behavior and generate coverage files for A/src as well?

I’ve figured this out. The argument to Pkg.test should be "user" or "@src", and not true. The combination that works is

julia --startup=no --project=downstream

followed by

julia> using Pkg

julia> Pkg.test(coverage="@src") # alternatively coverage="user"

The setting in Pkg.test is appended to the julia command, so passing coverage=true shadows the command-line flag with the package directory.

Unfortunately, this behavior is undocumented, so I’ve opened an issue about this