code-intelligence.com/cifuzz@v0.40.0/docs/Coverage-ide-integrations.md (about) 1 # Coverage IDE integrations 2 3 ## Jetbrains IDE's 4 5 ### CMake (in CLion) 6 7 You can start coverage runs from within CLion with the help of CMake 8 user presets. Custom cifuzz presets can be added by running: 9 10 cifuzz integrate cmake 11 12 Those presets have to be enabled before they show up as a run configuration. 13 See the [CLion documentation on presets 14 detection](https://www.jetbrains.com/help/clion/cmake-presets.html#detect) for 15 more details. 16 17  18 19 ### Bazel (in IntelliJ with Bazel Plugin) 20 21 To create a coverage report for your bazel project, these lines of code have 22 to be added to your `.bazelrc` file. 23 24 ``` 25 # Coverage with Replay (C/C++ only) 26 coverage --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:replay 27 coverage --@rules_fuzzing//fuzzing:cc_engine_instrumentation=none 28 coverage --@rules_fuzzing//fuzzing:cc_engine_sanitizer=none 29 coverage --instrument_test_targets 30 coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1 31 coverage --action_env=GCOV=llvm-profdata 32 coverage --action_env=BAZEL_LLVM_COV=llvm-cov 33 coverage --combined_report=lcov 34 coverage --experimental_use_llvm_covmap 35 coverage --experimental_generate_llvm_lcov 36 ``` 37 38 This allows bazel to run the fuzz tests with coverage. 39 40 You can start a coverage run by opening the bazel BUILD file and executing the 41 fuzz test defined with `cc_fuzz_test` with "Run ... with Coverage". 42 This will run the fuzz test with the finding inputs from the `*_inputs` directory 43 and produce a coverage report which can be viewed in your IDE **if the fuzz test 44 passes**. If the fuzz test fails, the bugs must be fixed before a coverage report 45 can be produced. 46 47  48 49 ### Maven/Gradle (in IntelliJ) 50 51 You can start a coverage with "Run ... with Coverage". This will run the 52 fuzz test with the finding inputs from the `*Inputs` directory in 53 your test resources and produce a coverage report. 54 55  56 57 ### Node.js (in IntelliJ) 58 59 You can start a coverage with "Run ... with Coverage". This will run the 60 fuzz test with the finding inputs from the `*.fuzz` directory next to 61 your fuzz test file. 62 63  64 65 ## VS Code 66 67 ### CMake/Maven/Gradle 68 69 You can start coverage runs from within VS Code with the help of tasks. See 70 [How to Integrate with External Tools via 71 Tasks](https://code.visualstudio.com/docs/editor/tasks) for more details. A 72 custom cifuzz coverage task can be added by running: 73 74 cifuzz integrate vscode 75 76 Coverage reports can be visualized with the 77 [Coverage Gutters extension](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters). 78 79  80 81 ### Bazel 82 83 Right now we do not support starting a coverage run directly from VSCode for Bazel, 84 but you can use a created coverage report with the 85 [Coverage Gutters extension](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters). 86 87 For this you have to create a coverage report with cifuzz by running: 88 89 cifuzz coverage --format lcov --output lcov.info <target> 90 91 The extension will pick up the results in the `lcov.info` file automatically 92 and visualize it inside VSCode.