Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: docs/ios/coverage.md

Issue 2789433004: Add tools for code coverage support in iOS. (Closed)
Patch Set: Nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Generate code coverage data
2
3 1. Build a test target for coverage:
4
5 ```
6 ninja -C out/Coverage-iphonesimulator ios_chrome_unittests
7 ```
8
9 Targets that support code coverage need to call
10 `coverage_util::ConfigureCoverageReportPath()`.
11 If you don't use `setup-gn.py`, you can set the gn argument
12 `ios_enable_coverage` to `true`.
13
14 1. Run the test target. If using Xcode, don't forget to set `Coverage` in the
15 target's scheme:
16
17 ![](images/coverage_xcode.png)
18
19 1. Find the `coverage.profraw` in the `Documents` folder of the app. You can
20 look in the console output of the instrumented target. For example:
21
22 ```
23 Coverage data at /Users/johndoe/Library/Developer/CoreSimulator/Devices/
24 82D642FA-FC18-4EDB-AFE0-A17454804BE4/data/Containers/Data/Application/
25 E6B2B898-CE13-4958-93F3-E8B500446381/Documents/coverage.profraw
26 ```
27
28 1. Create a `coverage.profdata` file out of the `coverage.profraw` file:
29
30 ```
31 xcrun llvm-profdata merge \
32 -o out/Coverage-iphonesimulator/coverage.profdata \
33 path/to/coverage.profraw
34 ```
35
36 1. To see the **line coverage** for *all the instrumented source files*:
37
38 ```
39 xcrun llvm-cov show \
40 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
41 -instr-profile=out/Coverage-iphonesimulator/coverage.profdata \
42 -arch=x86_64
43 ```
44
45 ![](images/llvm-cov_show.png)
46
47 To see the **line coverage** for a *specific instrumented source
48 file/folder* (e.g.
49 `ios/chrome/browser/ui/coordinators/browser_coordinator.mm`):
50
51 ```
52 xcrun llvm-cov show \
53 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
54 -instr-profile=out/Coverage-iphonesimulator/coverage.profdata \
55 -arch=x86_64 ios/chrome/browser/ui/coordinators/browser_coordinator.mm
56 ```
57
58 ![](images/llvm-cov_show_file.png)
59
60 To see a **complete report**:
61
62 ```
63 xcrun llvm-cov report \
64 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
65 -instr-profile=path/to/coverage.profdata -arch=x86_64
66 ```
67
68 ![](images/llvm-cov_report.png)
69
70 To see a **report** for a *folder/file* (e.g. `ios/chrome/browser` folder):
71
72 ```
73 xcrun llvm-cov show \
74 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
75 -instr-profile=path/to/coverage.profdata -arch=x86_64 ios/chrome/browser
76 ```
77
78 ![](images/llvm-cov_report_folder.png)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698