Ioannis Foukarakis
2012-11-17 16:47:28 UTC
Hi,
As this is my first email here, I'd like to grab the opportunity and thank
you for the great work!
I'd like to ask for some help on a problem I have setting up sonar with a
python project. I'm not sure if I'm doing something wrong or if I've hit a
bug. My project's structure is like the following:
[root folder]
- .pylint
- sonar-project.properties
- src (includes sources)
- tests (includes unit tests)
- testdata (some test data files for my tests)
- reports (generated code coverage and nosetests are added here.
My sonar-project.properties is pretty much like the following:
sonar.projectKey=this.is:myproject
sonar.projectName=New python project
sonar.projectVersion=1.0-SNAPSHOT
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=py
# Encoding of the source files
sonar.sourceEncoding=UTF-8
# JDBC for sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
# Code coverage
sonar.dynamicAnalysis=reuseReports
sonar.core.codeCoveragePlugin=cobertura
sonar.python.coverage.reportPath=reports/coverage.xml
# Test results
sonar.python.xunit.reportPath=reports/nosetests.xml
nosetests --with-xunit --with-coverage --cover-xml --cover-branches
--xunit-file=reports/nosetests.xml --cover-xml-file=reports/coverage.xml
Finally, if I execute sonar-runner, I get my project on sonar, and unit
tests are successfully reported. However neither pylint nor code coverage
are reported. I tried adding sonar.python.pylint_config=.pylintrc in
sonar-project.properties, but I got no results from pylint. I also tried
sonar-runner -X and saw some lines like the following (I edit it to remove
paths):
18:30:31.793 INFO .p.c.CoberturaParser - Parsing report '...<project
root>/reports/coverage.xml'
18:30:31.832 DEBUG PythonCoverageSensor - Cannot find the file 'afile.py',
ignoring coverage measures
18:30:31.832 DEBUG PythonCoverageSensor - Cannot find the file
'anotherfile.py', ignoring coverage measures
It looks like PythonCoverageSensor ignores sonar.sources property. I also
tried copying files under root folder and reports folder, and I still got
the same problem. Finally, I updated project's default coverage plugin to
"cobertura" and tried re-running sonar-runner, but I'm still getting the
same results. My configuration is the following:
Sonar version: 3.3.1
Runner version: 2.0
Python version 2.7.3
Thank you in advance for your time!
Kind regards,
Yiannis
As this is my first email here, I'd like to grab the opportunity and thank
you for the great work!
I'd like to ask for some help on a problem I have setting up sonar with a
python project. I'm not sure if I'm doing something wrong or if I've hit a
bug. My project's structure is like the following:
[root folder]
- .pylint
- sonar-project.properties
- src (includes sources)
- tests (includes unit tests)
- testdata (some test data files for my tests)
- reports (generated code coverage and nosetests are added here.
My sonar-project.properties is pretty much like the following:
sonar.projectKey=this.is:myproject
sonar.projectName=New python project
sonar.projectVersion=1.0-SNAPSHOT
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=py
# Encoding of the source files
sonar.sourceEncoding=UTF-8
# JDBC for sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
# Code coverage
sonar.dynamicAnalysis=reuseReports
sonar.core.codeCoveragePlugin=cobertura
sonar.python.coverage.reportPath=reports/coverage.xml
# Test results
sonar.python.xunit.reportPath=reports/nosetests.xml
From my understanding, I have to first run nosetests to generate unit tests
and code coverage reports. So I run it like this:nosetests --with-xunit --with-coverage --cover-xml --cover-branches
--xunit-file=reports/nosetests.xml --cover-xml-file=reports/coverage.xml
Finally, if I execute sonar-runner, I get my project on sonar, and unit
tests are successfully reported. However neither pylint nor code coverage
are reported. I tried adding sonar.python.pylint_config=.pylintrc in
sonar-project.properties, but I got no results from pylint. I also tried
sonar-runner -X and saw some lines like the following (I edit it to remove
paths):
18:30:31.793 INFO .p.c.CoberturaParser - Parsing report '...<project
root>/reports/coverage.xml'
18:30:31.832 DEBUG PythonCoverageSensor - Cannot find the file 'afile.py',
ignoring coverage measures
18:30:31.832 DEBUG PythonCoverageSensor - Cannot find the file
'anotherfile.py', ignoring coverage measures
It looks like PythonCoverageSensor ignores sonar.sources property. I also
tried copying files under root folder and reports folder, and I still got
the same problem. Finally, I updated project's default coverage plugin to
"cobertura" and tried re-running sonar-runner, but I'm still getting the
same results. My configuration is the following:
Sonar version: 3.3.1
Runner version: 2.0
Python version 2.7.3
Thank you in advance for your time!
Kind regards,
Yiannis