Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
guwirth committed Apr 8, 2021
1 parent 4d3d333 commit a1e86e0
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
22 changes: 22 additions & 0 deletions integration-tests/features/indexing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,25 @@ Feature: Indexing files
And the following metrics have following values:
| metric | value |
| files | None |


Scenario: Verify macro propagation
Read cacsaced include files. This works only if macros are
correct propagated from one include level to the next.

Given the project "macro_propagation_project"
When I run sonar-scanner with "-X"
Then the analysis finishes successfully
And the analysis in server has completed
And the analysis log contains no error/warning messages except those matching:
"""
.*WARN.*Unable to get a valid mac address, will use a dummy address
"""
And the following metrics have following values:
| metric | value |
| ncloc | 9 |
| lines | 31 |
| statements | 7 |
| classes | 0 |
| files | 3 |
| functions | 2 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# metadata
sonar.projectKey=macro_propagation_project

# disable SCM support
sonar.scm.disabled=true

# disable XML sensor
sonar.xml.file.suffixes=.disable-xml

# file extensions assigned to the cxx programming language
sonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h

# comma-separated paths to directories containing source files
sonar.sources=src
13 changes: 13 additions & 0 deletions integration-tests/testdata/macro_propagation_project/src/header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// header.h

#ifndef HEADER
#define HEADER

template<typename T>
void f();

#define HEADER_IMPL // The macro is set before including header.hpp
#include "header.hpp"
#undef HEADER_IMPL

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// header.hpp

#ifdef HEADER_IMPL // This is an ifdef, not an ifndef!

template<typename T>
void f() {
// do something...
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// main.cpp

#include "header.h"

int main(int argc, char *argv[]) {
f<int>();
return 0;
}

0 comments on commit a1e86e0

Please sign in to comment.