3737import static org .mockito .Mockito .mock ;
3838import static org .mockito .Mockito .times ;
3939import static org .mockito .Mockito .verify ;
40+ import org .sonar .plugins .cxx .utils .CxxUtils ;
4041
4142public class CxxBullseyeCoverageSensorTest {
4243
@@ -63,16 +64,16 @@ public void shouldReportCorrectCoverage() {
6364 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/coverage-result-bullseye-win.xml" );
6465 settings .setProperty (CxxCoverageSensor .IT_REPORT_PATH_KEY , "coverage-reports/bullseye/coverage-result-bullseye-win.xml" );
6566 settings .setProperty (CxxCoverageSensor .OVERALL_REPORT_PATH_KEY , "coverage-reports/bullseye/coverage-result-bullseye-win.xml" );
66- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/src/testclass.h" );
67- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/src/testclass.cpp" );
68- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/main.cpp" );
69- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/testclass.h" );
70- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/testclass.cpp" );
71- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/source_1.cpp" );
72- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/src/testclass.h" );
73- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/src/testclass.cpp" );
74- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/main.cpp" );
75- TestUtils .addInputFile (fs , perspectives , issuable , "d :/home/path/TESTCOV/testclass.h" );
67+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/src/testclass.h") );
68+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/src/testclass.cpp") );
69+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/main.cpp") );
70+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/testclass.h") );
71+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/testclass.cpp") );
72+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/source_1.cpp") );
73+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/src/testclass.h") );
74+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/src/testclass.cpp") );
75+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/main.cpp") );
76+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "c :/home/path/TESTCOV/testclass.h") );
7677 } else {
7778 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/coverage-result-bullseye-linux.xml" );
7879 settings .setProperty (CxxCoverageSensor .IT_REPORT_PATH_KEY , "coverage-reports/bullseye/coverage-result-bullseye-linux.xml" );
@@ -98,16 +99,16 @@ public void shoulParseTopLevelFiles() {
9899 Settings settings = new Settings ();
99100 if (TestUtils .isWindows ()) {
100101 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/bullseye-coverage-report-data-in-root-node-win.xml" );
101- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas/anotherincludeattop.h" );
102- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas/test/test.c" );
103- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas/test2/test2.c" );
104- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas/main.c" );
102+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas/anotherincludeattop.h") );
103+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas/test/test.c") );
104+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas/test2/test2.c") );
105+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas/main.c") );
105106 } else {
106107 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/bullseye-coverage-report-data-in-root-node-linux.xml" );
107- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test/anotherincludeattop.h" );
108- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test/test/test.c" );
109- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test/test2/test2.c" );
110- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test/main.c" );
108+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test/anotherincludeattop.h" );
109+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test/test/test.c" );
110+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test/test2/test2.c" );
111+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test/main.c" );
111112 }
112113 sensor = new CxxCoverageSensor (settings , fs , TestUtils .mockReactor ());
113114 sensor .analyse (project , context );
@@ -119,17 +120,17 @@ public void shoulCorrectlyHandleDriveLettersWithoutSlash() {
119120 Settings settings = new Settings ();
120121 if (TestUtils .isWindows ()) {
121122 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/bullseye-coverage-drive-letter-without-slash-win.xml" );
122- TestUtils .addInputFile (fs , perspectives , issuable , "e :/main.c" );
123- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas/test.c" );
124- TestUtils .addInputFile (fs , perspectives , issuable , "e :/randomfoldernamethatihopeknowmachinehas2/test2.c" );
125- TestUtils .addInputFile (fs , perspectives , issuable , "e :/anotherincludeattop.h" );
123+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/main.c") );
124+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas/test.c") );
125+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/randomfoldernamethatihopeknowmachinehas2/test2.c") );
126+ TestUtils .addInputFile (fs , perspectives , issuable , CxxUtils . normalizePath ( "C :/anotherincludeattop.h") );
126127 }
127128 else {
128129 settings .setProperty (CxxCoverageSensor .REPORT_PATH_KEY , "coverage-reports/bullseye/bullseye-coverage-drive-letter-without-slash-linux.xml" );
129- TestUtils .addInputFile (fs , perspectives , issuable , "/e /main.c" );
130- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test/test.c" );
131- TestUtils .addInputFile (fs , perspectives , issuable , "/e /test2/test2.c" );
132- TestUtils .addInputFile (fs , perspectives , issuable , "/e /anotherincludeattop.h" );
130+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /main.c" );
131+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test/test.c" );
132+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /test2/test2.c" );
133+ TestUtils .addInputFile (fs , perspectives , issuable , "/c /anotherincludeattop.h" );
133134 }
134135 sensor = new CxxCoverageSensor (settings , fs , TestUtils .mockReactor ());
135136 sensor .analyse (project , context );
0 commit comments