Workflow for faster testing of Julia packages?

Thanks!

Okay I think I got everything working. Thanks to everyone for your help.

Here’s my new workflow for getting rapid-fire code coverage updates:

  1. Start Julia with --code-coverage=@ to only track the current package you are developing.
julia \
    --code-coverage=@ \
    --code-coverage=lcov.info \  # To prevent generating the .cov files at exit; otherwise this is not needed
    --depwarn=yes \
    --project=.
  1. Use TestEnv.jl to load up all the test dependencies:
julia> using TestEnv; TestEnv.activate()
  1. Evaluate only the parts of the test suite you want to accumulate coverage for. (I recommend doing this by inclusion in a new module) –
julia> @eval module $(gensym())
           using Test; @testset begin
               include("test/test_parse.jl")
           end
       end;
Test Summary: | Pass  Total  Time
test set      |   54     54  0.6s
  1. Generate an LCOV-compatible coverage file:
julia> @ccall jl_write_coverage_data("lcov.info"::Cstring)::Cvoid

Now, lcov.info will appear in your current directory. If you use coverage gutters in VSCode (highly recommended), it will automatically detect this file and generate interactive code coverage metadata for your entire VSCode project.

  1. After making an edit to your unittests, and re-run (3) and (4) as many times as you want to update the coverage with the aggregate[^1]. It will be fast as you won’t have to restart Julia again!

Happy testing :metal:


P.S., if anybody knows the right function call to empty a StringMap< SmallVector<logdata_block*, 0> >, we could also automatically empty the coverage information. Otherwise it will just keep accumulating throughout the runtime.

P.P.S., I am not sure how this interacts with Revise. Maybe [P.S.] is needed for that, otherwise the line info would get thrown off. But maybe it’s fine…

4 Likes