Skip to content

Commit

Permalink
add case sensitive sample
Browse files Browse the repository at this point in the history
  • Loading branch information
guwirth committed Aug 23, 2024
1 parent 2a5f71f commit 663e5f5
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 3 deletions.
24 changes: 21 additions & 3 deletions integration-tests/features/json-db.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Feature: JSON Compilation Database support

As a CXX Plugin user, I want to use the JSON Compilation Database to analyze SonarQube projects

Scenario: Analyze only the source files contained in the JSON Compilation Database.
Given the project "json_db_project"
Scenario: Analyze only the source files contained in the JSON Compilation Database (case insensitive filesystem).
Given the project "json_db_project-case_insensitive"
And platform is "Windows"
When I run sonar-scanner with "-X"
Then the analysis finishes successfully
And the analysis in server has completed
Expand All @@ -13,7 +14,24 @@ Feature: JSON Compilation Database support
.*WARN.*Unable to get a valid mac address, will use a dummy address
"""
And the following metrics have following values:
| metric | value |
| metric | value |
| ncloc | 9 |
| lines | 24 |
| statements | 3 |
| functions | 3 |

Scenario: Analyze only the source files contained in the JSON Compilation Database (case sensitive filesystem).
Given the project "json_db_project-case_sensitive"
And platform is not "Windows"
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 | 24 |
| statements | 3 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"_comment_": "example extension to define global defines and includes for headers and for files which are not compiled",
"file": "__global__",
"defines": {
"GLOBAL_DEFINE": "1"
},
"includes": [
"/usr/include"
]
},
{
"_comment_": "source file to use",
"directory": "./src",
"file": "file1.cc",
"command": "gcc -o output1 -I/usr/local/include -I /another/include/dir -DSIMPLE1 -DCOMMAND_DEFINE=1 file1.cpp",
"output": "output1"
},
{
"_comment_": "source file to use",
"directory": "./src",
"file": "file2.cc",
"command": "gcc -o output2 -I/usr/local/include -I /another/include/dir -DSIMPLE2 -DCOMMAND_DEFINE=2 FILE2.cpp",
"output": "output2"
},
{
"_comment_": "source file to use",
"directory": "./src",
"file": "file3.cc",
"command": "gcc -o output3 -I/usr/local/include -I /another/include/dir -DSIMPLE3 -DCOMMAND_DEFINE=3 File3.cpp",
"output": "output3"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# metadata
sonar.projectKey=json_db_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

# read a JSON Compilation Database file
sonar.cxx.jsonCompilationDatabase=compile_commands.json
sonar.cxx.jsonCompilationDatabase.analyzeOnlyContainedFiles=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func2(){
return 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func3(){
return 3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func1(){
return 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func4(){
return 4;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func5(){
return 5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int func6(){
return 6;
}

0 comments on commit 663e5f5

Please sign in to comment.