From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <m.kokryashkin@tarantool.org> Cc: max.kokryashkin@gmail.com, tarantool-patches@dev.tarantool.org, Sergey Bronnikov <estetus@gmail.com> Subject: Re: [Tarantool-patches] [PATCH] cmake: add code coverage support Date: Tue, 1 Aug 2023 18:25:26 +0300 [thread overview] Message-ID: <58297844-8590-cf70-b3d5-3ed8908aef9a@tarantool.org> (raw) In-Reply-To: <62sqm37aohluqmyfgqgdeupxavzfnhszawdtns3yg7ctk5mppf@d535jjttice5> Hi, Max! thanks for your comments. See my comments below. On 7/30/23 16:34, Maxim Kokryashkin wrote: <snipped> > Here is the commit message on the branch: > | cmake: add code coverage support > | > | The patch adds building code coverage support using gcovr [1] and gcov. > | gcovr is a better version of lcov, see [2]. CMake target LuaJIT-coverage > | executes regression tests, proccess *.gcno and *.gcda files with gcov, > Typo: s/process/processes/ > | builds detailed HTML report and prints summary about code coverage. > Typo: s/detailed/a detailed > Typo: s/summary/a summary/ Fixed. <snipped> >> >>>> +if (ENABLE_COVERAGE) >>>> + AppendFlags(CMAKE_C_FLAGS >>>> + -fprofile-arcs >>>> + -ftest-coverage >>> Should we use just --coverage? >> Sure, updated. > Now the alignments seems kinda strange. I believe it would be > better to make it a signle line now, like: > | AppendFlags(CMAKE_C_FLAGS --coverage) Fixed. Actually I left it on a separate line intentionally. This will minimize a diff in case adding more options to CFLAGS. >>> | --coverage >>> | This option is used to compile and link code instrumented >>> | for coverage analysis. The option is a synonym for >>> | -fprofile-arcs -ftest-coverage (when compiling) and -lgcov >>> | (when linking). >>> >>> See man gcc(1) for details. >>> >>>> + ) >>>> +endif() >>>> + >>>> # Auxiliary flags for main targets (libraries, binaries). >>>> AppendFlags(TARGET_C_FLAGS >>>> -D_FILE_OFFSET_BITS=64 > I suggest moving most of the logic with finding gcov/running coverage into > a separate cmake module, just to make the test-related one more readable. > What do you think? Good idea. Moved to cmake/CodeCoverage.cmake. <snipped> >>>> + endif() >>>> + >>>> + add_custom_target(${PROJECT_NAME}-coverage) >>>> + add_custom_command(TARGET ${PROJECT_NAME}-coverage >>>> + COMMENT "Building coverage report" >>>> + COMMAND >>>> + ${GCOVR} >>>> + # See https://gcovr.com/en/stable/guide/configuration.html >>>> + --root ${PROJECT_SOURCE_DIR} >>>> + --filter ${PROJECT_SOURCE_DIR}/src >>> I suppose some files like *.dasc files or buildvm sources should be >>> excluded too, since they are not informative. >> Done. > You did not include the actual diff for the change, so I've checked it > on GitHub. Here are two comments, that were added: > | # Exclude DynASM files, that contains a low-level VM code for CPUs. > Typo: s/that contains/that contain/ > > | # Exclude buildvm source code, it's a project's infrastructure. > Typo: s/a project's/the project's/ Fixed. >> >>>> + --print-summary >>>> + --output ${COVERAGE_HTML_REPORT} >>>> + --coveralls ${COVERAGE_JSON_REPORT} >>> I see also output >>> >>>> + --html >>>> + --html-title "LuaJIT Code Coverage Report" >>>> + --html-details >>>> + --sort-percentage >>> I can't see an option for decreasing percentage of uncovered lines? >>> Is its default value? If it is, then it should be used (as far as we want >>> to see uncovered cases first). >> >> Seems it can sort in that order only. >> >>>> + --branches >>>> + --decisions >>> Do we need this option? AFAICS, this is mostly about Functional Safety >>> applications (road vehicles, etc.). >> I would leave it. >> >> >>>> + --verbose >>> I suppose that we should use --verbose option only when VERBOSE=1 env >>> var is set. >>> >>> Also, I'm suprised by lines like this: >>> | (DEBUG) Parsing coverage data for file /home/burii/reviews/luajit/gcov/src/lj_tab.h >>> | (DEBUG) Starting the decision analysis >>> | (DEBUG) Decision Analysis finished! >>> | (DEBUG) Finding source file corresponding to a gcov data file >>> Is it the part of the --verbose options? >> Right, it is enabled only when --verbose is passed. Removed option --verbose >> at all, >> >> I believe we don't need it in normal use. >> >> >>>> + -j ${CMAKE_BUILD_PARALLEL_LEVEL} >>>> + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} >>>> + ) >>>> + message(STATUS "Code coverage HTML report: ${COVERAGE_HTML_REPORT}") >>>> + message(STATUS "Code coverage JSON report: ${COVERAGE_JSON_REPORT}") >>>> +endif(ENABLE_COVERAGE) >>>> + >>>> if(LUAJIT_USE_TEST) >>>> if(POLICY CMP0037) >>>> if(CMAKE_VERSION VERSION_LESS 3.11) >>>> @@ -76,4 +114,6 @@ if(LUAJIT_USE_TEST) >>>> ${PROJECT_NAME}-test >>>> ${PROJECT_NAME}-luacheck >>>> ) >>>> + >>>> + add_dependencies(${PROJECT_NAME}-coverage ${PROJECT_NAME}-test) >>> Is it necessary to rerun all tests to generate this analisys every >>> time? >> What could be a reasons to regenerate coverage report without rerunning >> tests? >> >> I can make a target LuaJIT-coverage that will generate report and add target >> coverage that will >> >> run tests and then call LuaJIT-coverage. What do you think? > Seems adequate to me. Added: --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,6 +78,9 @@ if(LUAJIT_USE_TEST) ) if (LUAJIT_ENABLE_COVERAGE) - add_dependencies(${PROJECT_NAME}-coverage ${PROJECT_NAME}-test) + add_custom_target(coverage DEPENDS + ${PROJECT_NAME}-test + ${PROJECT_NAME}-coverage + ) endif (LUAJIT_ENABLE_COVERAGE) endif() <snipped> > Maxim Kokryashkin
next prev parent reply other threads:[~2023-08-01 15:25 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-25 13:52 Sergey Bronnikov via Tarantool-patches 2023-07-26 15:02 ` Sergey Kaplun via Tarantool-patches 2023-07-27 8:42 ` Sergey Bronnikov via Tarantool-patches 2023-07-30 12:55 ` Maxim Kokryashkin via Tarantool-patches 2023-07-30 13:34 ` Maxim Kokryashkin via Tarantool-patches 2023-08-01 15:25 ` Sergey Bronnikov via Tarantool-patches [this message] 2023-08-08 8:16 ` Sergey Bronnikov via Tarantool-patches 2023-08-08 10:47 ` Sergey Kaplun via Tarantool-patches 2023-08-08 19:25 ` Sergey Bronnikov via Tarantool-patches 2023-08-14 7:46 ` Maxim Kokryashkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=58297844-8590-cf70-b3d5-3ed8908aef9a@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=estetus@gmail.com \ --cc=m.kokryashkin@tarantool.org \ --cc=max.kokryashkin@gmail.com \ --cc=sergeyb@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] cmake: add code coverage support' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox