SonarOpenCommunity / sonar-cxx

SonarQube C++ Community plugin (cxx plugin): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools.
GNU Lesser General Public License v3.0
995 stars 364 forks source link

xUnit sensor not run on maven projects #1523

Closed Rots closed 6 years ago

Rots commented 6 years ago

https://github.com/SonarOpenCommunity/sonar-cxx/blob/d4fc380e8acf6d0357b56d7860eb1d5e7681abcf/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java#L88

The sonar.moduleKey seems to be set in maven executions for even root projects, so the xUnit reports are never parsed:

To test I created a simple sonar-cxx-plugin/integration-tests/testdata/googletest_project/pom.xml:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
</project>

and ran mvn sonar:sonar -Dsonar.cxx.xunit.reportPath=gtest.xml -Dsonar.sources=src -Dsonar.scm.disabled=true -Dsonar.tests=tests/unittests -X

[DEBUG] 12:16:11.735 Setting proxy properties
[DEBUG] 12:16:11.911 keyStore is : 
[DEBUG] 12:16:11.911 keyStore type is : jks
[DEBUG] 12:16:11.912 keyStore provider is : 
[DEBUG] 12:16:11.912 init keystore
[DEBUG] 12:16:11.912 init keymanager of type SunX509
[DEBUG] 12:16:11.985 Create: /usr/src/mymaven/.sonar/cache
[INFO] 12:16:11.990 User cache: /usr/src/mymaven/.sonar/cache
[DEBUG] 12:16:11.991 Create: /usr/src/mymaven/.sonar/cache/_tmp
[DEBUG] 12:16:12.002 Extract sonar-scanner-api-batch in temp...
[DEBUG] 12:16:12.009 Get bootstrap index...
[DEBUG] 12:16:12.010 Download: http://localhost:9000/batch/index
[DEBUG] 12:16:12.085 Get bootstrap completed
[DEBUG] 12:16:12.105 Create isolated classloader...
[DEBUG] 12:16:12.115 Start temp cleaning...
[DEBUG] 12:16:12.238 Temp cleaning done
[DEBUG] 12:16:12.239 Execution getVersion
[INFO] 12:16:12.242 SonarQube version: 7.1.0
[INFO] 12:16:12.274 Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
[DEBUG] 12:16:12.276 Work directory: /usr/src/mymaven/target/sonar
[DEBUG] 12:16:12.279 Execution execute
[INFO] 12:16:12.519 Publish mode
[INFO] 12:16:12.770 Load global settings
[DEBUG] 12:16:12.889 GET 200 http://localhost:9000/api/settings/values.protobuf | time=96ms
[INFO] 12:16:12.957 Load global settings (done) | time=188ms
[INFO] 12:16:12.974 Server id: AWSJWkZY7LLKB5Jkvodu
[INFO] 12:16:12.993 User cache: /usr/src/mymaven/.sonar/cache
[INFO] 12:16:13.482 Load plugins index
[DEBUG] 12:16:13.492 GET 200 http://localhost:9000/api/plugins/installed | time=10ms
[INFO] 12:16:13.573 Load plugins index (done) | time=91ms
[INFO] 12:16:13.573 Load/download plugins
[INFO] 12:16:13.758 Load/download plugins (done) | time=185ms
[DEBUG] 12:16:13.787 API compatibility mode is enabled on plugin PMD [pmd] (built with API lower than 5.2)
[DEBUG] 12:16:14.421 Plugins:
[DEBUG] 12:16:14.421   * PMD 2.6 (pmd)
[DEBUG] 12:16:14.422   * Branch 7.1 (branch)
[DEBUG] 12:16:14.422   * Svn 1.7.0.1017 (scmsvn)
[DEBUG] 12:16:14.422   * SonarPLSQL 3.2.0.1753 (plsql)
[DEBUG] 12:16:14.422   * SonarC# 7.2.0.5463 (csharp)
[DEBUG] 12:16:14.422   * SonarJava 5.5.0.14655 (java)
[DEBUG] 12:16:14.422   * LDAP 2.2.0.608 (ldap)
[DEBUG] 12:16:14.423   * SonarFlex 2.4.0.1222 (flex)
[DEBUG] 12:16:14.423   * SonarXML 1.5.1.1452 (xml)
[DEBUG] 12:16:14.423   * SonarTS 1.7.0.2893 (typescript)
[DEBUG] 12:16:14.423   * Checkstyle 4.10 (checkstyle)
[DEBUG] 12:16:14.423   * SonarVB 5.1.0.442 (vbnet)
[DEBUG] 12:16:14.423   * SonarSwift 3.3.0.2492 (swift)
[DEBUG] 12:16:14.423   * C++ (Community) 1.1.0 (cxx)
[DEBUG] 12:16:14.424   * SonarCFamily 5.1.0.10083 (cpp)
[DEBUG] 12:16:14.424   * SonarPython 1.10.0.2131 (python)
[DEBUG] 12:16:14.424   * SonarRPG 2.3.0.1187 (rpg)
[DEBUG] 12:16:14.424   * SonarPLI 1.9.0.1349 (pli)
[DEBUG] 12:16:14.424   * SonarTSQL 1.2.0.2539 (tsql)
[DEBUG] 12:16:14.424   * SonarVB6 2.4.0.1305 (vb)
[DEBUG] 12:16:14.424   * SonarJS 4.1.0.6085 (javascript)
[DEBUG] 12:16:14.424   * License 3.3.0.1341 (license)
[DEBUG] 12:16:14.425   * SonarCOBOL 4.3.0.3019 (cobol)
[DEBUG] 12:16:14.425   * Git 1.4.1.1128 (scmgit)
[DEBUG] 12:16:14.425   * SonarPHP 2.13.0.3107 (php)
[DEBUG] 12:16:14.425   * Developer 7.1 (developer)
[DEBUG] 12:16:14.425   * SonarABAP 3.6.0.1269 (abap)
[DEBUG] 12:16:14.425   * Governance 7.1 (governance)
[INFO] 12:16:15.202 Process project properties
[DEBUG] 12:16:15.217 Process project properties (done) | time=15ms
[INFO] 12:16:15.224 Load project branches
[DEBUG] 12:16:15.232 GET 200 http://localhost:9000/api/project_branches/list?project=com.mycompany.app%3Amy-app | time=7ms
[INFO] 12:16:15.245 Load project branches (done) | time=22ms
[INFO] 12:16:15.247 Load project pull requests
[DEBUG] 12:16:15.253 GET 200 http://localhost:9000/api/project_pull_requests/list?project=com.mycompany.app%3Amy-app | time=6ms
[INFO] 12:16:15.259 Load project pull requests (done) | time=13ms
[INFO] 12:16:15.260 Load branch configuration
[INFO] 12:16:15.263 Load branch configuration (done) | time=4ms
[INFO] 12:16:15.264 Load project repositories
[DEBUG] 12:16:15.272 GET 200 http://localhost:9000/batch/project.protobuf?key=com.mycompany.app%3Amy-app | time=8ms
[INFO] 12:16:15.362 Load project repositories (done) | time=98ms
[INFO] 12:16:15.434 Execute project builders
[INFO] 12:16:15.436 Execute project builders (done) | time=2ms
[DEBUG] 12:16:15.591 Available languages:
[DEBUG] 12:16:15.592   * PL/SQL => "plsql"
[DEBUG] 12:16:15.593   * C# => "cs"
[DEBUG] 12:16:15.594   * Java => "java"
[DEBUG] 12:16:15.594   * Flex => "flex"
[DEBUG] 12:16:15.595   * XML => "xml"
[DEBUG] 12:16:15.595   * TypeScript => "ts"
[DEBUG] 12:16:15.596   * Visual Basic .NET => "vbnet"
[DEBUG] 12:16:15.597   * Swift => "swift"
[DEBUG] 12:16:15.597   * C++ (Community) => "c++"
[DEBUG] 12:16:15.597   * C => "c"
[DEBUG] 12:16:15.598   * C++ => "cpp"
[DEBUG] 12:16:15.598   * Objective-C => "objc"
[DEBUG] 12:16:15.599   * Python => "py"
[DEBUG] 12:16:15.600   * RPG => "rpg"
[DEBUG] 12:16:15.600   * PL/I => "pli"
[DEBUG] 12:16:15.601   * T-SQL => "tsql"
[DEBUG] 12:16:15.601   * Vb => "vb"
[DEBUG] 12:16:15.602   * JavaScript => "js"
[DEBUG] 12:16:15.607   * COBOL => "cobol"
[DEBUG] 12:16:15.608   * PHP => "php"
[DEBUG] 12:16:15.609   * ABAP => "abap"
[INFO] 12:16:15.626 Load quality profiles
[DEBUG] 12:16:15.653 GET 200 http://localhost:9000/api/qualityprofiles/search.protobuf?projectKey=com.mycompany.app%3Amy-app | time=26ms
[INFO] 12:16:15.668 Load quality profiles (done) | time=43ms
[INFO] 12:16:15.687 Load active rules
[DEBUG] 12:16:15.749 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmna7LLKB5JkvqD_&p=1&ps=500 | time=61ms
[DEBUG] 12:16:15.897 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmna7LLKB5JkvqD_&p=2&ps=500 | time=35ms
[DEBUG] 12:16:15.955 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPSm5UYPa6yfp2pW&p=1&ps=500 | time=40ms
[DEBUG] 12:16:16.003 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPVx5UYPa6yfp2un&p=1&ps=500 | time=24ms
[DEBUG] 12:16:16.024 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPW05UYPa6yfp2xM&p=1&ps=500 | time=12ms
[DEBUG] 12:16:16.046 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWms97LLKB5Jkvqev&p=1&ps=500 | time=19ms
[DEBUG] 12:16:16.063 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmvj7LLKB5JkvqkR&p=1&ps=500 | time=11ms
[DEBUG] 12:16:16.150 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPYp5UYPa6yfp2yp&p=1&ps=500 | time=10ms
[DEBUG] 12:16:16.166 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPZQ5UYPa6yfp2zq&p=1&ps=500 | time=14ms
[DEBUG] 12:16:16.180 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPYB5UYPa6yfp2yD&p=1&ps=500 | time=11ms
[DEBUG] 12:16:16.204 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPaI5UYPa6yfp22P&p=1&ps=500 | time=21ms
[DEBUG] 12:16:16.243 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmk97LLKB5Jkvp2V&p=1&ps=500 | time=30ms
[DEBUG] 12:16:16.303 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmqC7LLKB5JkvqTO&p=1&ps=500 | time=42ms
[DEBUG] 12:16:16.338 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPeA5UYPa6yfp26T&p=1&ps=500 | time=19ms
[DEBUG] 12:16:16.361 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmrE7LLKB5JkvqYp&p=1&ps=500 | time=18ms
[DEBUG] 12:16:16.373 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmrm7LLKB5JkvqZa&p=1&ps=500 | time=8ms
[DEBUG] 12:16:16.391 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmt37LLKB5JkvqhR&p=1&ps=500 | time=17ms
[DEBUG] 12:16:16.409 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPfQ5UYPa6yfp28A&p=1&ps=500 | time=14ms
[DEBUG] 12:16:16.427 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPf55UYPa6yfp29h&p=1&ps=500 | time=14ms
[DEBUG] 12:16:16.452 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPib5UYPa6yfp3Cu&p=1&ps=500 | time=21ms
[DEBUG] 12:16:16.475 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJXPgj5UYPa6yfp2_Z&p=1&ps=500 | time=17ms
[DEBUG] 12:16:16.496 GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt&activation=true&qprofile=AWSJWmwD7LLKB5Jkvqli&p=1&ps=500 | time=14ms
[INFO] 12:16:16.540 Load active rules (done) | time=853ms
[INFO] 12:16:16.547 Load metrics repository
[DEBUG] 12:16:16.556 GET 200 http://localhost:9000/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=9ms
[INFO] 12:16:16.591 Load metrics repository (done) | time=44ms
[DEBUG] 12:16:16.606 SCM Step is disabled by configuration
[INFO] 12:16:16.618 Project key: com.mycompany.app:my-app
[INFO] 12:16:16.618 Project base dir: /usr/src/mymaven
[DEBUG] 12:16:16.619 Start recursive analysis of project modules
[INFO] 12:16:16.621 -------------  Scan my-app
[INFO] 12:16:16.922 Load server rules
[DEBUG] 12:16:16.990 GET 200 http://localhost:9000/api/rules/list.protobuf | time=68ms
[INFO] 12:16:17.059 Load server rules (done) | time=137ms
[INFO] 12:16:17.172 Base dir: /usr/src/mymaven
[INFO] 12:16:17.172 Working dir: /usr/src/mymaven/target/sonar
[INFO] 12:16:17.174 Source paths: src
[INFO] 12:16:17.175 Test paths: tests/unittests
[INFO] 12:16:17.175 Source encoding: UTF-8, default locale: en
[DEBUG] 12:16:17.311 Declared extensions of language PL/SQL were converted to sonar.lang.patterns.plsql : **/*.sql,**/*.pks,**/*.pkb
[DEBUG] 12:16:17.311 Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
[DEBUG] 12:16:17.311 Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
[DEBUG] 12:16:17.311 Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
[DEBUG] 12:16:17.311 Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl
[DEBUG] 12:16:17.312 Declared extensions of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx
[DEBUG] 12:16:17.312 Declared extensions of language Visual Basic .NET were converted to sonar.lang.patterns.vbnet : **/*.vb
[DEBUG] 12:16:17.312 Declared extensions of language Swift were converted to sonar.lang.patterns.swift : **/*.swift
[DEBUG] 12:16:17.312 Declared extensions of language C++ (Community) were converted to sonar.lang.patterns.c++ : **/*.cxx,**/*.cpp,**/*.cc,**/*.c,**/*.hxx,**/*.hpp,**/*.hh,**/*.h
[DEBUG] 12:16:17.313 Declared extensions of language C were converted to sonar.lang.patterns.c : **/*.c_unused
[DEBUG] 12:16:17.313 Declared extensions of language C++ were converted to sonar.lang.patterns.cpp : **/*.cc_unused
[DEBUG] 12:16:17.313 Declared extensions of language Objective-C were converted to sonar.lang.patterns.objc : **/*.m
[DEBUG] 12:16:17.313 Declared extensions of language Python were converted to sonar.lang.patterns.py : **/*.py
[DEBUG] 12:16:17.313 Declared extensions of language RPG were converted to sonar.lang.patterns.rpg : **/*.rpg,**/*.rpgle,**/*.rpg,**/*.rpgle
[DEBUG] 12:16:17.313 Declared extensions of language PL/I were converted to sonar.lang.patterns.pli : **/*.pli
[DEBUG] 12:16:17.314 Declared extensions of language T-SQL were converted to sonar.lang.patterns.tsql : **/*.tsql
[DEBUG] 12:16:17.314 Declared extensions of language Vb were converted to sonar.lang.patterns.vb : **/*.vb,**/*.bas,**/*.frm,**/*.cls,**/*.ctl,**/*.vb,**/*.bas,**/*.frm,**/*.cls,**/*.ctl
[DEBUG] 12:16:17.314 Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.vue
[DEBUG] 12:16:17.314 Declared extensions of language COBOL were converted to sonar.lang.patterns.cobol : 
[DEBUG] 12:16:17.314 Declared extensions of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
[DEBUG] 12:16:17.315 Declared extensions of language ABAP were converted to sonar.lang.patterns.abap : **/*.abap,**/*.ab4,**/*.flow,**/*.asprog
[DEBUG] 12:16:17.330 Initializers : 
[INFO] 12:16:17.332 Index files
[DEBUG] 12:16:17.369 'src/component1.hh' indexed with language 'c++'
[DEBUG] 12:16:17.371 'src/Makefile' indexed with language 'null'
[DEBUG] 12:16:17.372 'src/component1.cc' indexed with language 'c++'
[DEBUG] 12:16:17.373 'tests/unittests/Makefile' indexed as test with language 'null'
[DEBUG] 12:16:17.374 'tests/unittests/test_fname_in_tc.cc' indexed as test with language 'c++'
[DEBUG] 12:16:17.375 'tests/unittests/test_fname_in_both.cc' indexed as test with language 'c++'
[DEBUG] 12:16:17.378 'tests/unittests/test_without_fixture.cc' indexed as test with language 'c++'
[DEBUG] 12:16:17.377 'tests/unittests/test_fname_in_ts.cc' indexed as test with language 'c++'
[DEBUG] 12:16:17.379 'tests/unittests/test_two_fixtures.cc' indexed as test with language 'c++'
[DEBUG] 12:16:17.381 'tests/unittests/test_component1.cc' indexed as test with language 'c++'
[INFO] 12:16:17.386 10 files indexed
[INFO] 12:16:17.387 Quality profile for c++: Sonar way
[DEBUG] 12:16:17.985 Cyclomatic complexity threshold: 10
[DEBUG] 12:16:17.987 Function size threshold: 20
[DEBUG] 12:16:20.557 'Generic Coverage Report' skipped because one of the required properties is missing
[DEBUG] 12:16:20.558 'Generic Test Executions Report' skipped because one of the required properties is missing
[DEBUG] 12:16:20.559 'PL/SQL Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.559 'C#' skipped because there is no related file in current project
[DEBUG] 12:16:20.560 'C# Properties' skipped because there is no related file in current project
[DEBUG] 12:16:20.561 'C# Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.562 '[Deprecated] C# Integration Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.563 'C# Unit Test Results Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.563 'SurefireSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.563 'JaCoCoSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.564 'JavaSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.564 'Flex' skipped because there is no related file in current project
[DEBUG] 12:16:20.565 'Flex Cobertura' skipped because there is no related file in current project
[DEBUG] 12:16:20.565 'XML Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.566 'Import of TSLint issues' skipped because there is no related file in current project
[DEBUG] 12:16:20.566 'Import of ESLint issues' skipped because there is no related file in current project
[DEBUG] 12:16:20.567 'SonarTS' skipped because there is no related file in current project
[DEBUG] 12:16:20.567 'SonarTS Coverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.568 'VB.NET' skipped because there is no related file in current project
[DEBUG] 12:16:20.568 'VB.NET Properties' skipped because there is no related file in current project
[DEBUG] 12:16:20.569 'Visual Basic .NET Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.570 '[Deprecated] Visual Basic .NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.571 'Visual Basic .NET Unit Test Results Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.571 'Swift Squid Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.573 'C++ (Community) RatsSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.574 'C++ (Community) CppCheckSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.575 'C++ (Community) PCLintSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.576 'C++ (Community) DrMemorySensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.577 'C++ (Community) CompilerSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.578 'C++ (Community) VeraxxSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.580 'C++ (Community) ValgrindSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.581 'C++ (Community) ClangTidySensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.581 'C++ (Community) ClangSASensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.582 'C++ (Community) ExternalRulesSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.584 'C++ (Community) CoverageSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.585 'CFamily' skipped because there is no related file in current project
[DEBUG] 12:16:20.586 'gcov' skipped because there is no related file in current project
[DEBUG] 12:16:20.587 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 12:16:20.587 'cppunit' skipped because there is no related file in current project
[DEBUG] 12:16:20.588 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.588 'bullseye' skipped because there is no related file in current project
[DEBUG] 12:16:20.589 'Python Squid Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.589 'PylintSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.590 'PylintImportSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.590 'PythonXUnitSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.590 'RPG sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.591 'PliSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.591 'T-SQL Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.592 'VbSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.592 'SonarJS' skipped because there is no related file in current project
[DEBUG] 12:16:20.593 'SonarJS Coverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.593 'CobolSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.594 'PHP sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.594 'Analyzer for "php.ini" files' skipped because there is no related file in current project
[DEBUG] 12:16:20.594 'AbapSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.601 'Generic Coverage Report' skipped because one of the required properties is missing
[DEBUG] 12:16:20.602 'Generic Test Executions Report' skipped because one of the required properties is missing
[DEBUG] 12:16:20.602 'PL/SQL Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.602 'C#' skipped because there is no related file in current project
[DEBUG] 12:16:20.602 'C# Properties' skipped because there is no related file in current project
[DEBUG] 12:16:20.602 'C# Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 '[Deprecated] C# Integration Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 'C# Unit Test Results Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 'SurefireSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 'JaCoCoSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 'JavaSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.603 'Flex' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'Flex Cobertura' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'XML Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'Import of TSLint issues' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'Import of ESLint issues' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'SonarTS' skipped because there is no related file in current project
[DEBUG] 12:16:20.604 'SonarTS Coverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.605 'VB.NET' skipped because there is no related file in current project
[DEBUG] 12:16:20.605 'VB.NET Properties' skipped because there is no related file in current project
[DEBUG] 12:16:20.605 'Visual Basic .NET Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.605 '[Deprecated] Visual Basic .NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.605 'Visual Basic .NET Unit Test Results Import' skipped because there is no related file in current project
[DEBUG] 12:16:20.606 'Swift Squid Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.606 'C++ (Community) RatsSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.606 'C++ (Community) CppCheckSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.606 'C++ (Community) PCLintSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.606 'C++ (Community) DrMemorySensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.607 'C++ (Community) CompilerSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.607 'C++ (Community) VeraxxSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.607 'C++ (Community) ValgrindSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.607 'C++ (Community) ClangTidySensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.607 'C++ (Community) ClangSASensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.607 'C++ (Community) ExternalRulesSensor' skipped because there is no related rule activated in the quality profile
[DEBUG] 12:16:20.608 'C++ (Community) CoverageSensor' skipped because one of the required properties is missing
[DEBUG] 12:16:20.608 'CFamily' skipped because there is no related file in current project
[DEBUG] 12:16:20.608 'gcov' skipped because there is no related file in current project
[DEBUG] 12:16:20.608 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 12:16:20.609 'cppunit' skipped because there is no related file in current project
[DEBUG] 12:16:20.609 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.609 'bullseye' skipped because there is no related file in current project
[DEBUG] 12:16:20.609 'Python Squid Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.609 'PylintSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.610 'PylintImportSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.610 'PythonXUnitSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.610 'RPG sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.610 'PliSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.611 'T-SQL Sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.611 'VbSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.611 'SonarJS' skipped because there is no related file in current project
[DEBUG] 12:16:20.611 'SonarJS Coverage' skipped because there is no related file in current project
[DEBUG] 12:16:20.612 'CobolSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.612 'PHP sensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.612 'Analyzer for "php.ini" files' skipped because there is no related file in current project
[DEBUG] 12:16:20.612 'AbapSquidSensor' skipped because there is no related file in current project
[DEBUG] 12:16:20.613 Sensors : SonarJavaXmlFileSensor -> C++ (Community) SquidSensor -> C++ (Community) XunitSensor -> C++ (Community) Unit Test Results Import -> Zero Coverage Sensor -> CPD Block Indexer
[INFO] 12:16:20.614 Sensor SonarJavaXmlFileSensor [java]
[INFO] 12:16:20.614 Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
[INFO] 12:16:20.615 Sensor C++ (Community) SquidSensor [cxx]
[DEBUG] 12:16:20.747 global settings for: '/usr/src/mymaven/src/component1.cc'
[DEBUG] 12:16:20.748 Parse '/usr/src/mymaven/src/component1.cc' as C++ file
[DEBUG] 12:16:20.783 API File: component1.cc
[DEBUG] 12:16:20.783 Header file suffixes: [.hxx, .hpp, .hh, .h]
[DEBUG] 12:16:20.784 finished preprocessing '/usr/src/mymaven/src/component1.cc'
[DEBUG] 12:16:20.806 'src/component1.cc' generated metadata  with charset 'UTF-8'
[DEBUG] 12:16:20.818 Not enough content in 'src/component1.cc' to have CPD blocks, it will not be part of the duplication detection
[DEBUG] 12:16:20.838 CxxFileLinesVisitor: '/usr/src/mymaven/src/component1.cc'
[DEBUG] 12:16:20.839    lines:           '6'
[DEBUG] 12:16:20.839    executableLines: '[4]'
[DEBUG] 12:16:20.839    linesOfCode:     '[3, 4]'
[DEBUG] 12:16:20.839    linesOfComments: '[]'
[DEBUG] 12:16:20.859 global settings for: '/usr/src/mymaven/src/component1.hh'
[DEBUG] 12:16:20.859 Parse '/usr/src/mymaven/src/component1.hh' as C++ file
[DEBUG] 12:16:20.868 API File: component1.hh
[DEBUG] 12:16:20.868 Header file suffixes: [.hxx, .hpp, .hh, .h]
[DEBUG] 12:16:20.868 finished preprocessing '/usr/src/mymaven/src/component1.hh'
[DEBUG] 12:16:20.869 'src/component1.hh' generated metadata  with charset 'UTF-8'
[DEBUG] 12:16:20.870 ***** Node: classSpecifier tokenValue='class' tokenLine=4 tokenColumn=0
[DEBUG] 12:16:20.871 Public API: Bar
[DEBUG] 12:16:20.871 node: className line: 4 id: 'Bar' documented: false
[DEBUG] 12:16:20.872 ***** Node: memberDeclaration tokenValue='int' tokenLine=6 tokenColumn=4
[DEBUG] 12:16:20.872 Public API: foo
[DEBUG] 12:16:20.872 node: declaratorId line: 6 id: 'foo' documented: false
[DEBUG] 12:16:20.872 Not enough content in 'src/component1.hh' to have CPD blocks, it will not be part of the duplication detection
[DEBUG] 12:16:20.873 CxxFileLinesVisitor: '/usr/src/mymaven/src/component1.hh'
[DEBUG] 12:16:20.873    lines:           '9'
[DEBUG] 12:16:20.874    executableLines: '[]'
[DEBUG] 12:16:20.874    linesOfCode:     '[4, 5, 6]'
[DEBUG] 12:16:20.874    linesOfComments: '[]'
[INFO] 12:16:20.887 Sensor C++ (Community) SquidSensor [cxx] (done) | time=272ms
[INFO] 12:16:20.887 Sensor C++ (Community) XunitSensor [cxx]
[DEBUG] 12:16:20.888 Runs unit test import sensor only at top level project skip : Module Key = 'com.mycompany.app:my-app'
[INFO] 12:16:20.888 Sensor C++ (Community) XunitSensor [cxx] (done) | time=1ms
[INFO] 12:16:20.888 Sensor C++ (Community) Unit Test Results Import [cxx]
[DEBUG] 12:16:20.888 Exist configuration parameter: 'sonar.cxx.vstest.reportsPaths':'false'
[DEBUG] 12:16:20.888 Exist configuration parameter: 'sonar.cxx.xunit.reportsPaths':'false'
[DEBUG] 12:16:20.889 Exist configuration parameter: 'sonar.cxx.nunit.reportsPaths':'false'
[INFO] 12:16:20.889 No unit test results property. Skip Sensor
[INFO] 12:16:20.889 Sensor C++ (Community) Unit Test Results Import [cxx] (done) | time=1ms
[INFO] 12:16:20.889 Sensor Zero Coverage Sensor
[INFO] 12:16:20.921 Sensor Zero Coverage Sensor (done) | time=32ms
[INFO] 12:16:20.922 Sensor CPD Block Indexer
[DEBUG] 12:16:20.922 org.sonar.scanner.cpd.deprecated.DefaultCpdBlockIndexer is used for c++
[DEBUG] 12:16:20.922 No CpdMapping for language c++
[INFO] 12:16:20.923 Sensor CPD Block Indexer (done) | time=1ms
[INFO] 12:16:20.923 SCM Publisher is disabled
[INFO] 12:16:20.924 2 files had no CPD blocks
[INFO] 12:16:20.924 Calculating CPD for 0 files
[INFO] 12:16:20.929 CPD calculation finished
[DEBUG] 12:16:21.080 'tests/unittests/test_fname_in_tc.cc' generated metadata as test  with charset 'UTF-8'
[DEBUG] 12:16:21.082 'tests/unittests/test_fname_in_both.cc' generated metadata as test  with charset 'UTF-8'
[DEBUG] 12:16:21.083 'tests/unittests/test_fname_in_ts.cc' generated metadata as test  with charset 'UTF-8'
[DEBUG] 12:16:21.084 'tests/unittests/test_without_fixture.cc' generated metadata as test  with charset 'UTF-8'
[DEBUG] 12:16:21.086 'tests/unittests/test_two_fixtures.cc' generated metadata as test  with charset 'UTF-8'
[DEBUG] 12:16:21.088 'tests/unittests/test_component1.cc' generated metadata as test  with charset 'UTF-8'
[INFO] 12:16:21.146 Analysis report generated in 210ms, dir size=86 KB
[INFO] 12:16:21.173 Analysis reports compressed in 27ms, zip size=26 KB
[INFO] 12:16:21.173 Analysis report generated in /usr/src/mymaven/target/sonar/scanner-report
[DEBUG] 12:16:21.173 Upload report
[DEBUG] 12:16:21.194 POST 200 http://localhost:9000/api/ce/submit?projectKey=com.mycompany.app:my-app&projectName=my-app | time=18ms
[INFO] 12:16:21.197 Analysis report uploaded in 24ms
[INFO] 12:16:21.199 ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/com.mycompany.app:my-app
[INFO] 12:16:21.199 Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] 12:16:21.199 More about the report processing at http://localhost:9000/api/ce/task?id=AWTMN-Zr5UYPa6yfp3iD
[DEBUG] 12:16:21.200 Report metadata written to /usr/src/mymaven/target/sonar/report-task.txt
[DEBUG] 12:16:21.202 Post-jobs : 
[INFO] 12:16:21.207 Task total time: 6.759 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.718 s
[INFO] Finished at: 2018-07-24T12:16:21+00:00
[INFO] Final Memory: 39M/496M
[INFO] ------------------------------------------------------------------------

and in the log above you can see that the xUnit wasn't run with the log message that this has a moduleKey assigned:

[INFO] 12:16:20.887 Sensor C++ (Community) XunitSensor [cxx] [DEBUG] 12:16:20.888 Runs unit test import sensor only at top level project skip : Module Key = >'com.mycompany.app:my-app' [INFO] 12:16:20.888 Sensor C++ (Community) XunitSensor [cxx] (done) | time=1ms

ivangalkin commented 6 years ago

Hi @Rots and thank you for reaching out,

you are right in your assumption: the import is disabled by purpose. I assume, that whoever disabled it tried to suppress warning messages (there is a popular misunderstanding about scanning of multi-module projects, please read #1508 if interested).

I believe, that there is no justification to keep this limitation anymore. @guwirth is that correct? can we remove the check?

ivangalkin commented 6 years ago

Hi All,

I took a closer look at CxxXunitSensor and found out, that it's not able to distinguish, which test-case belongs to which (sub-)module. So the standard algorithm for a sensor doesn't work here:

  1. As long there are modules in the project
  2. For each module parse the report
  3. Distinguish, which report entry belongs to this particular module (check if affected file is in module)
  4. Store results for this particular module and continue with 0 ...
  5. Aggregate results over all modules for the project (root module) level

Accepting the sensor on the project level only is a valid solution in this case. The price of this workaround is a lack of a test results for sub-modules.

The right solution for the root project detection is to check the module definition. The following diff shows the main principle (not for production!). One has to pass ProjectDefinition while creation of the sensor (see CxxUnitTestResultsImportSensor).

I will take care of this issue.

diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
index e174f0c..9963cd2 100644
--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
@@ -30,6 +30,7 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.stream.StreamSource;
+
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
 import org.sonar.api.measures.CoreMetrics;
@@ -86,7 +87,7 @@ public class CxxXunitSensor extends CxxReportSensor {
   @Override
   public void execute(SensorContext context) {
     String moduleKey = context.config().get("sonar.moduleKey").orElse(null);
-    if (moduleKey != null) {
+    if (((DefaultInputModule) context.module()).definition().getParent() != null) {
       LOG.debug("Runs unit test import sensor only at top level project skip : Module Key = '{}'", moduleKey);
       return;
     }
guwirth commented 6 years ago

I believe, that there is no justification to keep this limitation anymore. @guwirth is that correct? can we remove the check?

@ivangalkin I'm sorry I can't tell you that. Think we have the problem that this feature was growing over the time and SQ versions. I don't use the multi-module feature I know only that we had a lot of trouble with it over the time.

Think makes sense to fix it / verify it again with SQ 6.7 LTS. I'm also wondering if the wiki is still valid? https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Path-and-path-separator-issues