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

Unified Diff: docs/ios/coverage.md

Issue 2789433004: Add tools for code coverage support in iOS. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: docs/ios/coverage.md
diff --git a/docs/ios/coverage.md b/docs/ios/coverage.md
new file mode 100644
index 0000000000000000000000000000000000000000..c0dab797dfded40516398a14ad02bd4080d04ed7
--- /dev/null
+++ b/docs/ios/coverage.md
@@ -0,0 +1,54 @@
+# Generate code coverage data
+
+1. Setup: Code coverage is only supported for Debug-iphonesimulator builds.
+ (gtest_include_ios_coverage, ENABLE_TEST_CODE_COVERAGE?)
+
+1. Run a test target that supports code coverage, for example
+ `ios_showcase_egtests`. Targets that support test target call
+ `coverage_util::SetupIfNecessary()`.
+
+1. Find the `coverage.profraw` in the Documents folder of the app. You can look
+ in the console output of the instrumented target. For example:
+
+ ```Coverage data at: </Users/johndoe/Library/Developer/CoreSimulator/Devices/\
+ 82D642FA-FC18-4EDB-AFE0-A17454804BE4/data/Containers/Data/Application/\
+ E6B2B898-CE13-4958-93F3-E8B500446381/Documents/coverage.profraw>```
+
+1. Create a `coverage.profdata` file out of the `coverage.profraw` file:
+
+ `xcrun llvm-profdata merge -o out/Debug-iphonesimulator/coverage.profdata
+ path/to/coverage.profraw`
+
+1. To see the **line coverage** for *all the instrumented source files*:
+
+ `xcrun llvm-cov show
+ out/Debug-iphonesimulator/ios_showcase_egtests.app/ios_showcase_egtests
+ -instr-profile=path/to/coverage.profdata -arch=x86_64`
+
+ ![](images/llvm-cov_show.png)
+
+ To see the **line coverage** for a *specific instrumented source
+ file/folder* (e.g. `ios/showcase/core/app_delegate.mm`):
+
+ `xcrun llvm-cov show
+ out/Debug-iphonesimulator/ios_showcase_egtests.app/ios_showcase_egtests
+ -instr-profile=path/to/coverage.profdata -arch=x86_64
+ ios/showcase/core/app_delegate.mm`
+
+ ![](images/llvm-cov_show_file.png)
+
+ To see a **complete report**:
+
+ `xcrun llvm-cov report
+ out/Debug-iphonesimulator/ios_showcase_egtests.app/ios_showcase_egtests
+ -instr-profile=path/to/coverage.profdata -arch=x86_64`
+
+ ![](images/llvm-cov_report.png)
+
+ To see a **report** for a *folder/file* (e.g. `ios/showcase/core` folder):
+
+ `xcrun llvm-cov show
+ out/Debug-iphonesimulator/ios_showcase_egtests.app/ios_showcase_egtests
+ -instr-profile=path/to/coverage.profdata -arch=x86_64 ios/showcase/core`
+
+ ![](images/llvm-cov_report_folder.png)

Powered by Google App Engine
This is Rietveld 408576698