本篇分享如何使用 Gcov 和 LCOV 对 C/C++ 项目进行代码覆盖率的度量。
如果你想了解代码覆盖率工具 Gcov 是如何工作的,或是以后需要做 C/C++ 项目的代码覆盖率,希望本篇对你有所帮助。
本篇分享如何使用 Gcov 和 LCOV 对 C/C++ 项目进行代码覆盖率的度量。
如果你想了解代码覆盖率工具 Gcov 是如何工作的,或是以后需要做 C/C++ 项目的代码覆盖率,希望本篇对你有所帮助。
In my opinion, SonarQube is not a very easy setup DevOps tool to compare with Jenkins, Artifactory. You can’t just run some script under the bin folder to let the server boot up.
You must have an installed database, configuration LDAP in the config file, etc.
So I’d like to document some important steps for myself, like setup LDAP or PostgreSQL when I install SonarQube of v9.0.1. It would be better if it can help others.
Need to be installed JRE/JDK 11 on the running machine.
Here is the prerequisites overview: https://docs.sonarqube.org/latest/requirements/requirements/
Download SonarQube: https://www.sonarqube.org/downloads/
cd sonarqube/ |
I installed SonarQube on CentOS 7 machine, the Java version is OpenJDK 1.8.0_242 by default, but the prerequisite shows at least need JDK 11. There is also JDK 11 available on my machine, so I just need to change the Java version.
I recommend using the alternatives
command change Java version,refer as following:
$ java -version |
SonarQube needs you to have installed a database. It supports several database engines, like Microsoft SQL Server, Oracle, and PostgreSQL. Since PostgreSQL is open source, light, and easy to install, so I choose PostgreSQL as its database.
How to download and install PostgreSQL please see this page: https://www.postgresql.org/download/linux/redhat/
Please refer to the sonar.properties
file at the end of this post.
sonar.security.realm=LDAP |
Comment out ldap.followReferrals=false
in sonar.properties file would be help.
Related post: https://community.sonarsource.com/t/ldap-login-takes-2-minutes-the-first-time/1573/7
I want to display Javascript code coverage result in SonarQube, so I added sonar.javascript.lcov.reportPaths=coverage/lcov.info
to the sonar-project.properties
But when I run sonar-scanner.bat
in the command line, the code coverage result can not show in sonar. I noticed the following error from the output:
INFO: Analysing [C:\workspace\xvm-ide\client\coverage\lcov.info] |
There are some posts related to this problem, for example, https://github.com/kulshekhar/ts-jest/issues/542, but no one works in my case.
# here is an example error path in lcov.info |
Finally, I have to use the sed
command to remove ..\
in front of the paths before running sonar-scanner.bat
, then the problem was solved.
sed -i 's/\..\\//g' lcov.info |
Please comment if you can solve the problem with changing options in the tsconfig.json
file.
To output more logs, change sonar.log.level=INFO
to sonar.log.level=DEBUG
in below.
Note: all above changes of
sonar.properties
need to restart the SonarQube instance to take effect.
sonar.properties
For the sonar.properties
file, please see below or link
When you want to add build status to your Bitbucket the specific commit of a branch when you start a build from the branch
When the build status is wrong, you want to update it manually. for example, update build status from FAILED to SUCCESSFUL
You can call Bitbucket REST API to do these.
Below is the code snippet to update Bitbucket build status with REST API in the shell script.
The code on GitHub Gist: https://gist.github.com/shenxianpeng/bd5eddc5fb39e54110afb8e2e7a6c4fb
Click Read More to view the code here.
This article shares how to use Gcov and LCOV to metrics code coverage for C/C++ projects.
If you want to know how Gcov works, or you need to metrics code coverage for C/C++ projects later,
I hope this article is useful to you.
I’ve run into some situations when the build fails, perhaps because some processes don’t finish, and even setting a timeout doesn’t make the Jenkins job fail.
So, to fix this problem, I used try
.. catch
and error
to make my Jenkins job failed, hopes this also helps you.
最近使用 AIX 7.1 从 Bitbucket 下载代码的时候遇到了这个错误:
最近在我使用 Artifactory Enterprise 遇到了上传制品非常缓慢的问题,在经过与 IT,Artifactory 管理员一起合作终于解决这个问题,在此分享一下这个问题的解决过程。
如果你也遇到类似或许有所帮助。
I’m just documenting to myself that it was solved by following.
When I want to integrate the ESlint report with Jenkins. I encourage a problem
That is eslint-report.html display different with it on my local machine, and I also log to Jenkins server and grab the eslint-report.html to local, it works well.
I used HTML Publisher plugin to display the HTML report, but only the ESlint HTML report has problems other report work well, so I guess this problem may be caused by Jenkins.
Finally, I find it. (Stackoverflow URL)
在使用 Git 提交代码之前,建议做以下这些设置。
叫指南有点夸张,因为它在有些情况下下不适用,比如你已经有了 .gitattributes
或 .editorconfig
等文件,那么有些设置就不用做了。
因此暂且叫他指北吧,它通常情况下还是很有用的。
废话不多说,看看都需要哪些设置吧。
To better manage the branches on Git(I sued Bitbucket), integration with CI tool, Artifactory, and automation will be more simple and clear.
For example, good unified partition naming can help the team easily find and integrate without special processing. Therefore, you should unify the partition naming rules for all repositories.
Today I am having a problem where the Windows installer I created is not installing, and the following Windows installer box pops up.
But it works well in the previous build, and I didn’t make any code changes. It is strange, actually fix this problem is very easy but not easy to find.