Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bdd/multimodule test #359

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions integration-tests/features/multimodule_analysis.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: cpp-multimodule-project

Test multimodule project with reports at root of the project

Scenario: cpp-multimodule-project
GIVEN the project "cpp-multimodule-project"
WHEN I run "sonar-runner -X"
THEN the analysis finishes successfully
AND the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*cannot find the sources for '#include <gtest/gtest\.h>'
.*WARN.*cannot find the sources for '#include <iostream>'
.*WARN - Cannot find the file '.*component_XXX.cc', skipping violations
.*WARN.*to create a dependency with .*
"""
AND the following metrics have following values:
| metric | value |
# size metrics
| ncloc | 56 |
| lines | 148 |
| statements | 36 |
| classes | 1 |
| files | 8 |
| directories | 4 |
| functions | 5 |
# comments / documentation
| comment_lines_density | 30 |
| comment_lines | 24 |
# duplications
| duplicated_lines_density | 58.1 |
| duplicated_lines | 86 |
| duplicated_blocks | 2 |
| duplicated_files | 2 |
# complexity
| complexity | 7 |
| function_complexity | 1.4 |
| file_complexity | 0.9 |
| class_complexity | 6 |
# violations
| violations | 20 |

69 changes: 69 additions & 0 deletions integration-tests/testdata/cpp-multimodule-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.sonar

#ignore thumbnails created by windows
Thumbs.db

# Ignore files built by Visual Studio
*.aps
*.bak
*.bu
*.cache
*.DotSettings
*.idb
*.ilk
*.log
*.metaproj
*.ncb
*.obj
*.opensdf
*.pch
*.pdb
*.sbr
*.sdf
*.sonar
*.suo
*.tlb
*.tlh
*.tmp
*.user
*.vspscc
*.vsscc
*_p.c

# Developer tool generated files
*My Amplifier XE Results - *
*My Inspector XE Results - *
*StyleCop.Cache
*.orig
*.rej
*unittest-report*
*.swp

#Movies
*.avi
*.mkv
*.mpg

#Folders with generated stuff
**/target/sonar/
BuildDrop/
ObjDrop/
bin/
bin_x64/
bin_release/
bin_release_x64/
ipch/
obj/
[Dd]ebug/
[Rr]elease/
[Tt]est[Rr]esult*/
_ReSharper*/

# Other version control
.svn/
*.MySCMServerInfo

# TS stuff
*.tlog
*.lastbuildstate
packages/
43 changes: 43 additions & 0 deletions integration-tests/testdata/cpp-multimodule-project/MultiModule.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cli", "cli\cli.vcxproj", "{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}"
ProjectSection(ProjectDependencies) = postProject
{244156B5-9F81-44AD-B81C-1B6DC4C8F35D} = {244156B5-9F81-44AD-B81C-1B6DC4C8F35D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib", "lib\lib.vcxproj", "{244156B5-9F81-44AD-B81C-1B6DC4C8F35D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package1", "package1\package1.vcxproj", "{3B981A84-73B2-4F67-911B-7E963E6A76D0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package2", "package2\package2.vcxproj", "{DE3F21E7-216A-4FDA-95FC-0CEB9C5D9A75}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}.Debug|Win32.ActiveCfg = Debug|Win32
{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}.Debug|Win32.Build.0 = Debug|Win32
{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}.Release|Win32.ActiveCfg = Release|Win32
{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}.Release|Win32.Build.0 = Release|Win32
{244156B5-9F81-44AD-B81C-1B6DC4C8F35D}.Debug|Win32.ActiveCfg = Debug|Win32
{244156B5-9F81-44AD-B81C-1B6DC4C8F35D}.Debug|Win32.Build.0 = Debug|Win32
{244156B5-9F81-44AD-B81C-1B6DC4C8F35D}.Release|Win32.ActiveCfg = Release|Win32
{244156B5-9F81-44AD-B81C-1B6DC4C8F35D}.Release|Win32.Build.0 = Release|Win32
{3B981A84-73B2-4F67-911B-7E963E6A76D0}.Debug|Win32.ActiveCfg = Debug|Win32
{3B981A84-73B2-4F67-911B-7E963E6A76D0}.Debug|Win32.Build.0 = Debug|Win32
{3B981A84-73B2-4F67-911B-7E963E6A76D0}.Release|Win32.ActiveCfg = Release|Win32
{3B981A84-73B2-4F67-911B-7E963E6A76D0}.Release|Win32.Build.0 = Release|Win32
{DE3F21E7-216A-4FDA-95FC-0CEB9C5D9A75}.Debug|Win32.ActiveCfg = Debug|Win32
{DE3F21E7-216A-4FDA-95FC-0CEB9C5D9A75}.Debug|Win32.Build.0 = Debug|Win32
{DE3F21E7-216A-4FDA-95FC-0CEB9C5D9A75}.Release|Win32.ActiveCfg = Release|Win32
{DE3F21E7-216A-4FDA-95FC-0CEB9C5D9A75}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
89 changes: 89 additions & 0 deletions integration-tests/testdata/cpp-multimodule-project/cli/cli.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1D884F0D-B01A-4DB0-AD6B-F375D1D07517}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>cli</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\lib.vcxproj">
<Project>{244156b5-9f81-44ad-b81c-1b6dc4c8f35d}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cc">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
#include "../lib/component1.hh"

int main(int argc, char* argv[])
{
std::cout << "Here is main" << std::endl;
return Bar().foo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Basic settings -->
<PropertyGroup>
<!-- Prevents double inclusion of root configuration propers if project included with this condition -->
<RootConfigurationIncluded>yes</RootConfigurationIncluded>

<!-- Main Versions Numbers For Tekla Structures -->
<MajorVersionNumber Condition="'$(MajorVersionNumber)'==''">3</MajorVersionNumber>
<MinorVersionNumber Condition="'$(MinorVersionNumber)'==''">0</MinorVersionNumber>
<BuildNumber Condition="'$(BuildNumber)'==''">0</BuildNumber>
<RevisionNumber Condition="'$(RevisionNumber)'==''">0</RevisionNumber>
<AssemblyPatcherTaskOn Condition="'$(AssemblyPatcherTaskOn)'==''">false</AssemblyPatcherTaskOn>
<!-- When set to true, file version and assembly version will be inline in c# assemblies -->
<PatchBuildNumberIntoCsAssembly Condition="'$(PatchBuildNumberIntoCsAssembly)'==''">false</PatchBuildNumberIntoCsAssembly>
<OverridePlatformToolSet Condition="'$(OverridePlatformToolSet)'==''">false</OverridePlatformToolSet>
</PropertyGroup>

<PropertyGroup>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset Condition="'$(OverridePlatformToolSet)'!='false'">$(PlatformToolset)</PlatformToolset>
</PropertyGroup>

<PropertyGroup>
<OBJDir>$(MSBuildThisFileDirectory)ObjDrop\$(SolutionName)\$(PlatformToolset)\$(Configuration)\$(Platform)</OBJDir>
<IntDir>$(OBJDir)\$(PlatformToolset)\$(ProjectName)\</IntDir>
<IntermediateOutputPath>$(OBJDir)\$(PlatformToolset)\$(ProjectName)\</IntermediateOutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)|$(Configuration)'=='Win32|Debug'">
<OutDir>$(MSBuildThisFileDirectory)BuildDrop\$(PlatformToolset)\Win32\Debug\</OutDir>
<OutDirTest>$(MSBuildThisFileDirectory)BuildDrop\Test\$(PlatformToolset)\Win32\Debug\</OutDirTest>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(Configuration)'=='x64|Debug'">
<OutDir>$(MSBuildThisFileDirectory)BuildDrop\$(PlatformToolset)\x64\Debug\</OutDir>
<OutDirTest>$(MSBuildThisFileDirectory)BuildDrop\Test\$(PlatformToolset)\x64\Debug\</OutDirTest>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(Configuration)'=='Win32|Release'">
<OutDir>$(MSBuildThisFileDirectory)BuildDrop\$(PlatformToolset)\Win32\Release\</OutDir>
<OutDirTest>$(MSBuildThisFileDirectory)BuildDrop\Test\$(PlatformToolset)\Win32\Release\</OutDirTest>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)|$(Configuration)'=='x64|Release'">
<OutDir>$(MSBuildThisFileDirectory)BuildDrop\$(PlatformToolset)\x64\Release\</OutDir>
<OutDirTest>$(MSBuildThisFileDirectory)BuildDrop\Test\$(PlatformToolset)\x64\Release\</OutDirTest>
</PropertyGroup>

<PropertyGroup>
<MSBuildTasksFolder>..\..\..\..\MSBuild</MSBuildTasksFolder>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <iostream>

#include \
"component1.hh"

/**
* Does something
*
* @return: an int indicating something
*/
int Bar::foo(){
// single line comment

/*
* multi-line comment
*/
int \
x; //unused variable

return 111;
}


void Bar::do_valgrind_errors(){
///// lets provoke some valgrind errors /////

// Memory leak (definitely lost)
new float();

// Condition depends on undefined value
int a;
if(a) std::cout << "fired!!!" << std::endl;

// Invalid read
int* ip = new int(0);
delete ip;
int i = *ip;

// Invalid write
ip = new int(0);
delete ip;
*ip = 1;

// Invalid free
ip = new int(0);
delete ip;
delete ip;

// Mismatched free() / delete / delete []
ip = new int(0);
delete [] ip;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef COMPONENT1_HH
#define COMPONENT1_HH

class Bar {
public:
int foo();
void do_valgrind_errors();
};
#endif
Loading