You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rewords some of the instructions in the README for local coverage measurement. The major changes & their motivations are:
- indicate the purpose of each step before describing the mechanics of the step. This also makes it easier to indicate that one does not necessarily need to measure summary statistics if one's only goal is to find lines lacking coverage.
- prioritize `Pkg.test(; coverage=true)` above manual measurement. Most users will want the simpler option.
- clarify the role of the `.info` tracefile. This allows users to determine when they need to supply the more complex set of options. By presenting it as a choice it also makes it clearer that you don't need to execute both lines.
- acknowledge limitations in the accuracy of Julia's coverage analysis
Copy file name to clipboardExpand all lines: README.md
+16-8Lines changed: 16 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,22 +22,25 @@ Most users will want to use [Coverage.jl](https://github.com/JuliaCI/Coverage.jl
22
22
23
23
### Code coverage
24
24
25
-
*Step 1:* Navigate to your test directory, and run julia with the `--code-coverage` option:
25
+
*Step 1: collect coverage data.* If you are using your default test suite, you can collect coverage data with `Pkg.test("MyPkg"; coverage=true)`. Alternatively, you can collect coverage data manually: in the terminal, navigate to whatever directory you want to start from as the working directory, and run julia with the `--code-coverage` option:
26
+
26
27
```sh
27
28
julia --code-coverage=user
29
+
```
30
+
or more comprehensively (if you're interested in getting coverage for Julia's standard libraries)
31
+
```sh
28
32
julia --code-coverage=tracefile-%p.info --code-coverage=user # available in Julia v1.1+
29
33
```
34
+
You can add other options (e.g., `--project`) as needed. After the REPL starts, execute whatever commands you wish, and then quit Julia. Coverage data are written to files when Julia exits.
30
35
31
-
*Step 2:* Run your tests (e.g., `include("runtests.jl")`) and quit Julia. (If you use `Pkg.test` to run your tests, set the `coverage` keyword argument to `true`, i.e. `Pkg.test("MyPkg"; coverage=true)`.)
32
-
33
-
*Step 3:* Navigate to the top-level directory of your package, restart Julia (with no special flags) and analyze your code coverage:
36
+
*Step 2: collect summary statistics (optional).* Navigate to the top-level directory of your package, restart Julia (with no special flags) and analyze your code coverage:
34
37
35
38
```julia
36
39
using Coverage
37
40
# process '*.cov' files
38
41
coverage =process_folder() # defaults to src/; alternatively, supply the folder name as argument
0 commit comments