diff --git a/integration-tests/features/indexing.feature b/integration-tests/features/indexing.feature index 4058aa9ab3..3664cb1be1 100644 --- a/integration-tests/features/indexing.feature +++ b/integration-tests/features/indexing.feature @@ -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 | diff --git a/integration-tests/testdata/macro_propagation_project/sonar-project.properties b/integration-tests/testdata/macro_propagation_project/sonar-project.properties new file mode 100644 index 0000000000..e4a8eb5024 --- /dev/null +++ b/integration-tests/testdata/macro_propagation_project/sonar-project.properties @@ -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 diff --git a/integration-tests/testdata/macro_propagation_project/src/header.h b/integration-tests/testdata/macro_propagation_project/src/header.h new file mode 100644 index 0000000000..27442a8dff --- /dev/null +++ b/integration-tests/testdata/macro_propagation_project/src/header.h @@ -0,0 +1,13 @@ +// header.h + +#ifndef HEADER +#define HEADER + +template +void f(); + +#define HEADER_IMPL // The macro is set before including header.hpp +#include "header.hpp" +#undef HEADER_IMPL + +#endif diff --git a/integration-tests/testdata/macro_propagation_project/src/header.hpp b/integration-tests/testdata/macro_propagation_project/src/header.hpp new file mode 100644 index 0000000000..586b721a58 --- /dev/null +++ b/integration-tests/testdata/macro_propagation_project/src/header.hpp @@ -0,0 +1,10 @@ +// header.hpp + +#ifdef HEADER_IMPL // This is an ifdef, not an ifndef! + +template +void f() { + // do something... +} + +#endif diff --git a/integration-tests/testdata/macro_propagation_project/src/main.cpp b/integration-tests/testdata/macro_propagation_project/src/main.cpp new file mode 100644 index 0000000000..42db729536 --- /dev/null +++ b/integration-tests/testdata/macro_propagation_project/src/main.cpp @@ -0,0 +1,8 @@ +// main.cpp + +#include "header.h" + +int main(int argc, char *argv[]) { + f(); + return 0; +}