Can not get code coverage for Lua project

Hi Team,

I am using below configuration for SonarQube:

SonaQube :- Community Edition Version 7.7 (build 23042)
sonar-scanner-3.3.0.1492-linux
sonar-lua-plugin-1.0.jar

I am trying to run SonarQube for Lua project. And I want anyalze the Lua code.

I have installed sonar-lua-plugin-1.0.jar and sonar-scanner-3.3.0.1492-linux. And i tried to run sonar-scanner.
I am able to see Bugs, Vulnerablities, code-smells and duplications but i am not able to get code coverage for that.

I tried to add source and tests in sonar-project.properties file and tried again same issue is there.

sonar-project.properties file content as below:

sonar.projectKey=testProject:Sample
sonar.projectName=Sample
sonar.projectVersion=1.0
sonar.sources=/home/Sample/src/
sonar.language=lua
sonar.tests=/home/Sample/test_luaAdd.lua

So is there any plugin for Lua as like Jacoco?

Please assist me on above problem.

1 Like

Hi,

I don’t believe the author of the Lua plugin did anything specific for coverage. However, you might be able to generate a coverage report and convert it to the Generic Coverage format.

 
Ann

Hi Ann,
we are using lua plugin and have created generic coverage reports as well as the generic execution reports and since we have changed to SonarQube 7.7 (coming from SonarQube 6.x) these two reports are no longer working.
Do you have a guess what could be the cause?

Hi, we use busted to run tests and luacov for coverage reports.
The tests reports have to be converted to generic execution format to be used in SonarQube.

Hi @Tuedi,

Without any of your analysis logs or error messages I can only guess.

 
Ann

Hi @Tuedi ,

Can you point me on how you’ve converted test reports to generic execution format used in SonarQube? Also, how you used luacov.stats.out in SonarQube?

Thanks,
Marjan

Hi Marjan,

we have converted the TAP output using a small java program.

I’ve also tried to write my own output library that is used directly by busted.

This is not fully working.

Why are you asking?

Kind regards

Christoph

Hi Tuedi,

Thanks. I’m asking because sonar-lua plugin is outdated and cannot be used in newer SonarQube versions. There is a plugin https://github.com/britzl/luacov-cobertura, which generates cobertura output from luacov. Maybe this can be used in SonarQube?

Thanks,
Marjan

Hi Marjan,

I think we also have the luacov-cobertura installed.

The problem that I’m focussing on it that since a specific version of sonarcube no lua unit tests are analysed any more.

At present we are running with lua code analysis but without code coverage and unit tests (which is a pitty)

Kind regards

Christoph

Hi Tuedi,

Yes, it’s a pitty that currently it is not possible to do that in a simple way.

Thank you for feedback.

Best regards,
Marjan

Hi Ann, I’ve made a small tiny project trying to find the problem with the lua issue.
I could manage to load lua in my environment with 7.3 but no longer with 7.8.
I could provide a tar ball of the tiny project if it would help.
When I look at sonarqube Plugin Version Matrix, I see that lua is no longer marked a compatible.

  • What does this mean?
  • What is the incompatibility your developers found?

Kind regards
TĂĽdi

Hi Tudi,

A few months before we remove deprecated APIs, the developers will usually do a sweep to see what Marketplace plugins are using those APIs to give them one final notification. Then when they drop the APIs we have a list of the plugins that have just lost compatibility and those plugins get marked incompatible starting with the next release.

What the specific API in question is, I couldn’t tell you.

 
HTH,
Ann

Hi Ann,

thanks for the fast reply.

What the specific API in question is, I couldn’t tell you.

OK, so I may have to check more myself, but what bothers me is the fact, that lua analysis is still done,

but the code coverage and the unit tests are no longer recognized all thought we are using the same xml-files as before.

busted-test-report.xml.txt (274 Bytes)
lua.report.xml.txt (419 Bytes)

in addition the following two files contain the log from sonar-scanner (slightly modified by reducing the time stamp) to give you as much information as possible.
sonar-7-3.log.no-ts.txt (21.4 KB)
sonar-7-8.log.no-ts.txt (25.3 KB)

and here is the sonar-project.properties file.
sonar-project.properties.txt (524 Bytes)

Do you have a clue?

Kind regards

TĂĽdi

Hi,

I don’t know what more I can tell you. The plugin was marked incompatible because of an API change.

 
Ann

Hi Ann,

sorry, asking again, but from the Documentation I understood the for all languages the “Generic Execution” format is working out of the bos without any language specific parts.
And this is what we are doing with the two xml files.

https://docs.sonarqube.org/latest/analysis/generic-test/

If this does not work as I thought, please let me know

Kind regards
TĂĽdi

Hi,

Generic test data only works for recognized languages. I believe there’s a ticket in the backlog to change that, but there’s no priority on that.

 
Ann