From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id EBC7D56B386; Tue, 8 Aug 2023 11:16:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EBC7D56B386 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1691482613; bh=NCdmglxlLrLUd2FrGGF3VdkXq/xuKxpw36wymZpxvP4=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NhFNS6VzmrcFcz3B00LHAy/f+e9ImbSMO4tmoz1otgNTgcZzgFrbisI7Rozuh2T5Q Xla0p/hgo+e78fV/p8E2XhzbIo0mK8/2sRx0M8JXl10E2GYKPRCcyd0c1gxcbPr/js 964JH76QBBzGsfOMNOtiTx/B83K9zv9joaO20lP0= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [95.163.41.100]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4DF9456A9A3 for ; Tue, 8 Aug 2023 11:16:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4DF9456A9A3 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1qTHta-005rWQ-0D; Tue, 08 Aug 2023 11:16:50 +0300 Message-ID: <696ac7ac-b93d-84ff-3285-f1a848c6bdde@tarantool.org> Date: Tue, 8 Aug 2023 11:16:49 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Sergey Bronnikov , tarantool-patches@dev.tarantool.org, Sergey Kaplun , max.kokryashkin@gmail.com References: <4a26e6a1f06191178c385a1df62d61763a5743e3.1690293120.git.sergeyb@tarantool.org> Content-Language: en-US In-Reply-To: <4a26e6a1f06191178c385a1df62d61763a5743e3.1690293120.git.sergeyb@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD969E04B5EED670DC868303E4FA23A046C075EC7AC197E9C0B182A05F538085040FAD45148C770F702F047F370C442668863E4D482ACE8A56BB976E901181E00EA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FFA2A8BF6367A61CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372BE3E2E75E3847F48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D808641875E3CAAE909797ABDC0146DD64117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1E57F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520599709FD55CB46A66FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B1269E641683F5DD3FD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE34E7D9683544204AF302FCEF25BFAB345C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407978DA827A17800CE773BC869C69ECC1572DBA43225CD8A89FB26E97DCB74E62525E1C53F199C2BB95B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5448E20189C9DF095E3A0726E9EA7A4DAD50A6C4727D14192F87CCE6106E1FC07E67D4AC08A07B9B01DAA61796BF5227BCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF2E544AA23102A418AEBE05D191E31AC6F03D9A4AD529C765A19155324D9C25C9F2D331BABA2AF9051529AA6C8ABD04CAD725AB74B3487D647048FC163FF54DA8A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj/xSHLV4ZQPslyrqn2PUhlA== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A76929E9029922725B38F047F370C4426688DDEE725E12766E67EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] cmake: add code coverage support X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hello, Unfortunately we cannot control order of running dependencies for target. On practice we can get a situation when target LuaJIT-coverage, that generates a code coverage report, runs before finishing target LuaJIT-test, that generates code coverage data. Therefore target "coverage" that combined LuaJIT-test and LuaJIT-coverage, has been removed by patch below. Updated patches force-pushed. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 78abf2e1..13ea6c5b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -50,8 +50,10 @@ jobs:        - name: build          run: cmake --build . --parallel          working-directory: ${{ env.BUILDDIR }} -      - name: test and generate code coverage report -        run: cmake --build ${{ env.BUILDDIR }} --parallel --target coverage +      - name: run regression tests +        run: cmake --build ${{ env.BUILDDIR }} --parallel --target test +      - name: generate code coverage report +        run: cmake --build ${{ env.BUILDDIR }} --parallel --target LuaJIT-coverage        - name: send code coverage to coveralls.io          run: |            curl -LO https://coveralls.io/coveralls-linux.tar.gz diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e23d6d45..47296a22 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -76,11 +76,4 @@ if(LUAJIT_USE_TEST)      ${PROJECT_NAME}-test      ${PROJECT_NAME}-luacheck    ) - -  if (LUAJIT_ENABLE_COVERAGE) -    add_custom_target(coverage DEPENDS -      ${PROJECT_NAME}-test -      ${PROJECT_NAME}-coverage -    ) -  endif (LUAJIT_ENABLE_COVERAGE)  endif() Sergey On 7/25/23 16:52, Sergey Bronnikov wrote: > From: Sergey Bronnikov > > The patch adds building code coverage report 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, > builds detailed HTML report and prints summary about code coverage. > > ``` > $ cmake -S . -B build -DENABLE_COVERAGE=ON > $ cmake --build build --parallel > $ cmake --build build --target LuaJIT-coverage > > > > lines: 84.1% (26056 out of 30997) > functions: 88.8% (2055 out of 2314) > branches: 71.5% (14801 out of 20703) > ``` > > 1. https://gcovr.com/ > 2. https://gcovr.com/en/stable/faq.html#what-is-the-difference-between-lcov-and-gcovr > --- > CMakeLists.txt | 9 ++++++ > test/CMakeLists.txt | 40 +++++++++++++++++++++++++++ > test/tarantool-c-tests/CMakeLists.txt | 2 +- > 3 files changed, 50 insertions(+), 1 deletion(-) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index 6ef24bba..8bc63b90 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -116,6 +116,15 @@ if(LUAJIT_ENABLE_WARNINGS) > ) > endif() > > +set(ENABLE_COVERAGE_DEFAULT OFF) > +option(ENABLE_COVERAGE "Enable integration with gcovr, a code coverage program" ${ENABLE_COVERAGE_DEFAULT}) > +if (ENABLE_COVERAGE) > + AppendFlags(CMAKE_C_FLAGS > + -fprofile-arcs > + -ftest-coverage > + ) > +endif() > + > # Auxiliary flags for main targets (libraries, binaries). > AppendFlags(TARGET_C_FLAGS > -D_FILE_OFFSET_BITS=64 > diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt > index 47296a22..9b0f11d8 100644 > --- a/test/CMakeLists.txt > +++ b/test/CMakeLists.txt > @@ -59,6 +59,44 @@ add_custom_target(${PROJECT_NAME}-test DEPENDS > tarantool-tests > ) > > +find_program(GCOVR gcovr) > +find_program(GCOV gcov) > +set(COVERAGE_HTML_REPORT "luajit-coverage.html") > +set(COVERAGE_JSON_REPORT "luajit-coverage.json") > +if(ENABLE_COVERAGE) > + if(NOT GCOVR OR NOT GCOV) > + add_custom_target(${PROJECT_NAME}-coverage) > + add_custom_command(TARGET ${PROJECT_NAME}-coverage > + COMMENT "Either `gcovr' or `gcov` not found, so ${PROJECT_NAME}-coverage target is dummy" > + ) > + return() > + 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 > + --print-summary > + --output ${COVERAGE_HTML_REPORT} > + --coveralls ${COVERAGE_JSON_REPORT} > + --html > + --html-title "LuaJIT Code Coverage Report" > + --html-details > + --sort-percentage > + --branches > + --decisions > + --verbose > + -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) > endif() > diff --git a/test/tarantool-c-tests/CMakeLists.txt b/test/tarantool-c-tests/CMakeLists.txt > index 17255345..8cd76b44 100644 > --- a/test/tarantool-c-tests/CMakeLists.txt > +++ b/test/tarantool-c-tests/CMakeLists.txt > @@ -45,7 +45,7 @@ foreach(test_source ${tests}) > OUTPUT_NAME "${exe}${C_TEST_SUFFIX}" > RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" > ) > - target_link_libraries(${exe} libtest ${LUAJIT_LIBRARY}) > + target_link_libraries(${exe} libtest ${LUAJIT_LIBRARY} --coverage) > LIST(APPEND TESTS_COMPILED ${exe}) > endforeach() >