OLD | NEW |
(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  |
| 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  |
| 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  |
| 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  |
| 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  |
OLD | NEW |