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

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

Issue 2789433004: Add tools for code coverage support in iOS. (Closed)
Patch Set: Feedback 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::SetupIfNecessary()`.
11
12 1. Run the test target. If using Xcode, don't forget to set `Coverage` in the
13 target's scheme:
14
15 ![](images/coverage_xcode.png)
16
17 1. Find the `coverage.profraw` in the `Documents` folder of the app. You can
18 look in the console output of the instrumented target. For example:
19
20 ```
21 Coverage data at /Users/johndoe/Library/Developer/CoreSimulator/Devices/
22 82D642FA-FC18-4EDB-AFE0-A17454804BE4/data/Containers/Data/Application/
23 E6B2B898-CE13-4958-93F3-E8B500446381/Documents/coverage.profraw
24 ```
25
26 1. Create a `coverage.profdata` file out of the `coverage.profraw` file:
27
28 ```
29 xcrun llvm-profdata merge \
30 -o out/Coverage-iphonesimulator/coverage.profdata \
31 path/to/coverage.profraw
32 ```
33
34 1. To see the **line coverage** for *all the instrumented source files*:
35
36 ```
37 xcrun llvm-cov show \
38 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
39 -instr-profile=out/Coverage-iphonesimulator/coverage.profdata \
40 -arch=x86_64
41 ```
42
43 ![](images/llvm-cov_show.png)
44
45 To see the **line coverage** for a *specific instrumented source
46 file/folder* (e.g.
47 `ios/chrome/browser/ui/coordinators/browser_coordinator.mm`):
48
49 ```
50 xcrun llvm-cov show \
51 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
52 -instr-profile=out/Coverage-iphonesimulator/coverage.profdata \
53 -arch=x86_64 ios/chrome/browser/ui/coordinators/browser_coordinator.mm
54 ```
55
56 ![](images/llvm-cov_show_file.png)
57
58 To see a **complete report**:
59
60 ```
61 xcrun llvm-cov report \
62 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
63 -instr-profile=path/to/coverage.profdata -arch=x86_64
64 ```
65
66 ![](images/llvm-cov_report.png)
67
68 To see a **report** for a *folder/file* (e.g. `ios/chrome/browser` folder):
69
70 ```
71 xcrun llvm-cov show \
72 out/Coverage-iphonesimulator/ios_chrome_unittests.app/ios_chrome_unittes ts \
73 -instr-profile=path/to/coverage.profdata -arch=x86_64 ios/chrome/browser
74 ```
75
76 ![](images/llvm-cov_report_folder.png)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698