Changeset View
Changeset View
Standalone View
Standalone View
outputview/tests/test_filteringstrategy.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 35 | switch (type) { | |||
---|---|---|---|---|---|
46 | case FilteredItem::StandardItem: | 46 | case FilteredItem::StandardItem: | ||
47 | return qstrdup("StandardItem"); | 47 | return qstrdup("StandardItem"); | ||
48 | case FilteredItem::WarningItem: | 48 | case FilteredItem::WarningItem: | ||
49 | return qstrdup("WarningItem"); | 49 | return qstrdup("WarningItem"); | ||
50 | } | 50 | } | ||
51 | return qstrdup("unknown"); | 51 | return qstrdup("unknown"); | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | inline QTestData& newRowForPathType(const char *dataTag, TestPathType pathType) | ||||
55 | { | ||||
56 | if (pathType == UnixFilePathWithSpaces) { | ||||
57 | return QTest::newRow(QString(QLatin1String(dataTag)+QLatin1String("-ws")).toUtf8().constData()); | ||||
58 | } | ||||
59 | return QTest::newRow(dataTag); | ||||
60 | } | ||||
61 | | ||||
54 | } | 62 | } | ||
55 | 63 | | |||
56 | void TestFilteringStrategy::testNoFilterStrategy_data() | 64 | void TestFilteringStrategy::testNoFilterStrategy_data() | ||
57 | { | 65 | { | ||
58 | QTest::addColumn<QString>("line"); | 66 | QTest::addColumn<QString>("line"); | ||
59 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected"); | 67 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected"); | ||
60 | 68 | | |||
61 | QTest::newRow("cppcheck-info-line") | 69 | QTest::newRow("cppcheck-info-line") | ||
62 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem; | 70 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem; | ||
63 | QTest::newRow("cppcheck-error-line") | 71 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
64 | << buildCppCheckErrorLine() << FilteredItem::InvalidItem; | 72 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
65 | QTest::newRow("compiler-line") | 73 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem; | ||
66 | << buildCompilerLine() << FilteredItem::InvalidItem; | 74 | QTest::newRowForPathType("compiler-line", pathType) | ||
67 | QTest::newRow("compiler-error-line") | 75 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem; | ||
68 | << buildCompilerErrorLine() << FilteredItem::InvalidItem; | 76 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
77 | << buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem; | ||||
78 | } | ||||
69 | QTest::newRow("compiler-action-line") | 79 | QTest::newRow("compiler-action-line") | ||
70 | << buildCompilerActionLine() << FilteredItem::InvalidItem; | 80 | << buildCompilerActionLine() << FilteredItem::InvalidItem; | ||
71 | QTest::newRow("compiler-information-line") | 81 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
72 | << buildCompilerInformationLine() << FilteredItem::InvalidItem; | 82 | QTest::newRowForPathType("compiler-information-line", pathType) | ||
73 | QTest::newRow("python-error-line") | 83 | << buildCompilerInformationLine(pathType) << FilteredItem::InvalidItem; | ||
74 | << buildPythonErrorLine() << FilteredItem::InvalidItem; | 84 | QTest::newRowForPathType("python-error-line", pathType) | ||
85 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem; | ||||
86 | } | ||||
75 | } | 87 | } | ||
76 | 88 | | |||
77 | void TestFilteringStrategy::testNoFilterStrategy() | 89 | void TestFilteringStrategy::testNoFilterStrategy() | ||
78 | { | 90 | { | ||
79 | QFETCH(QString, line); | 91 | QFETCH(QString, line); | ||
80 | QFETCH(FilteredItem::FilteredOutputItemType, expected); | 92 | QFETCH(FilteredItem::FilteredOutputItemType, expected); | ||
81 | NoFilterStrategy testee; | 93 | NoFilterStrategy testee; | ||
82 | FilteredItem item1 = testee.errorInLine(line); | 94 | FilteredItem item1 = testee.errorInLine(line); | ||
83 | QCOMPARE(item1.type, expected); | 95 | QCOMPARE(item1.type, expected); | ||
84 | item1 = testee.actionInLine(line); | 96 | item1 = testee.actionInLine(line); | ||
85 | QCOMPARE(item1.type, expected); | 97 | QCOMPARE(item1.type, expected); | ||
86 | } | 98 | } | ||
87 | 99 | | |||
88 | void TestFilteringStrategy::testCompilerFilterStrategy_data() | 100 | void TestFilteringStrategy::testCompilerFilterStrategy_data() | ||
89 | { | 101 | { | ||
90 | QTest::addColumn<QString>("line"); | 102 | QTest::addColumn<QString>("line"); | ||
91 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | 103 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | ||
92 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | 104 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | ||
105 | QTest::addColumn<TestPathType>("pathType"); | ||||
93 | 106 | | |||
94 | QTest::newRow("cppcheck-info-line") | 107 | QTest::newRow("cppcheck-info-line") | ||
95 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 108 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
96 | QTest::newRow("cppcheck-error-line") | 109 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
97 | << buildCppCheckErrorLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 110 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
98 | QTest::newRow("compiler-line") | 111 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
99 | << buildCompilerLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 112 | QTest::newRowForPathType("compiler-line", pathType) | ||
100 | QTest::newRow("compiler-error-line") | 113 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
101 | << buildCompilerErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 114 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
102 | QTest::newRow("compiler-information-line") | 115 | << buildCompilerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
103 | << buildCompilerInformationLine() << FilteredItem::InformationItem << FilteredItem::InvalidItem; | 116 | QTest::newRowForPathType("compiler-information-line", pathType) | ||
104 | QTest::newRow("compiler-information-line2") | 117 | << buildCompilerInformationLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
105 | << buildInfileIncludedFromFirstLine() << FilteredItem::InformationItem << FilteredItem::InvalidItem; | 118 | QTest::newRowForPathType("compiler-information-line2", pathType) | ||
106 | QTest::newRow("compiler-information-line3") | 119 | << buildInfileIncludedFromFirstLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
107 | << buildInfileIncludedFromSecondLine() << FilteredItem::InformationItem << FilteredItem::InvalidItem; | 120 | QTest::newRowForPathType("compiler-information-line3", pathType) | ||
121 | << buildInfileIncludedFromSecondLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||||
122 | } | ||||
108 | QTest::newRow("cmake-error-line1") | 123 | QTest::newRow("cmake-error-line1") | ||
109 | << "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 124 | << "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
110 | QTest::newRow("cmake-error-multiline1") | 125 | QTest::newRow("cmake-error-multiline1") | ||
111 | << "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 126 | << "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
112 | QTest::newRow("cmake-error-multiline2") | 127 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
113 | << buildCmakeConfigureMultiLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 128 | QTest::newRowForPathType("cmake-error-multiline2", pathType) | ||
129 | << buildCmakeConfigureMultiLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||||
130 | } | ||||
114 | QTest::newRow("cmake-warning-line") | 131 | QTest::newRow("cmake-warning-line") | ||
115 | << "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem; | 132 | << "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
116 | QTest::newRow("cmake-automoc-error") | 133 | QTest::newRow("cmake-automoc-error") | ||
117 | << "AUTOMOC: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 134 | << "AUTOMOC: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
118 | QTest::newRow("cmake-automoc4-error") | 135 | QTest::newRow("cmake-automoc4-error") | ||
119 | << "automoc4: The file \"/foo/bar.cpp\" includes the moc file \"bar1.moc\"" << FilteredItem::InformationItem << FilteredItem::InvalidItem; | 136 | << "automoc4: The file \"/foo/bar.cpp\" includes the moc file \"bar1.moc\"" << FilteredItem::InformationItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
120 | QTest::newRow("cmake-autogen-error") | 137 | QTest::newRow("cmake-autogen-error") | ||
121 | << "AUTOGEN: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 138 | << "AUTOGEN: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
122 | QTest::newRow("linker-action-line") | 139 | QTest::newRow("linker-action-line") | ||
123 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem; | 140 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem << UnixFilePathNoSpaces; | ||
124 | QTest::newRow("linker-error-line") | 141 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
125 | << buildLinkerErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 142 | QTest::newRowForPathType("linker-error-line", pathType) | ||
126 | QTest::newRow("python-error-line") | 143 | << buildLinkerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
127 | << buildPythonErrorLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 144 | QTest::newRowForPathType("python-error-line", pathType) | ||
145 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||||
146 | } | ||||
128 | } | 147 | } | ||
129 | 148 | | |||
130 | void TestFilteringStrategy::testCompilerFilterStrategy() | 149 | void TestFilteringStrategy::testCompilerFilterStrategy() | ||
131 | { | 150 | { | ||
132 | QFETCH(QString, line); | 151 | QFETCH(QString, line); | ||
133 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | 152 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | ||
134 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | 153 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | ||
135 | QUrl projecturl = QUrl::fromLocalFile( projectPath() ); | 154 | QFETCH(TestPathType, pathType); | ||
155 | | ||||
156 | QUrl projecturl = QUrl::fromLocalFile( projectPath(pathType) ); | ||||
136 | CompilerFilterStrategy testee(projecturl); | 157 | CompilerFilterStrategy testee(projecturl); | ||
137 | FilteredItem item1 = testee.errorInLine(line); | 158 | FilteredItem item1 = testee.errorInLine(line); | ||
138 | QCOMPARE(item1.type, expectedError); | 159 | QCOMPARE(item1.type, expectedError); | ||
139 | item1 = testee.actionInLine(line); | 160 | item1 = testee.actionInLine(line); | ||
140 | QCOMPARE(item1.type, expectedAction); | 161 | QCOMPARE(item1.type, expectedAction); | ||
141 | } | 162 | } | ||
142 | 163 | | |||
143 | void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords_data() | 164 | void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords_data() | ||
Show All 32 Lines | |||||
176 | void TestFilteringStrategy::testScriptErrorFilterStrategy_data() | 197 | void TestFilteringStrategy::testScriptErrorFilterStrategy_data() | ||
177 | { | 198 | { | ||
178 | QTest::addColumn<QString>("line"); | 199 | QTest::addColumn<QString>("line"); | ||
179 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | 200 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | ||
180 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | 201 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | ||
181 | 202 | | |||
182 | QTest::newRow("cppcheck-info-line") | 203 | QTest::newRow("cppcheck-info-line") | ||
183 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 204 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | ||
184 | QTest::newRow("cppcheck-error-line") | 205 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
185 | << buildCppCheckErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 206 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
186 | QTest::newRow("compiler-line") | 207 | << buildCppCheckErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | ||
187 | << buildCompilerLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 208 | QTest::newRowForPathType("compiler-line", pathType) | ||
188 | QTest::newRow("compiler-error-line") | 209 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | ||
189 | << buildCompilerErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 210 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
211 | << buildCompilerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | ||||
212 | } | ||||
190 | QTest::newRow("compiler-action-line") | 213 | QTest::newRow("compiler-action-line") | ||
191 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 214 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | ||
192 | QTest::newRow("python-error-line") | 215 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
193 | << buildPythonErrorLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 216 | QTest::newRowForPathType("python-error-line", pathType) | ||
217 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | ||||
218 | } | ||||
194 | } | 219 | } | ||
195 | 220 | | |||
196 | void TestFilteringStrategy::testScriptErrorFilterStrategy() | 221 | void TestFilteringStrategy::testScriptErrorFilterStrategy() | ||
197 | { | 222 | { | ||
198 | QFETCH(QString, line); | 223 | QFETCH(QString, line); | ||
199 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | 224 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | ||
200 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | 225 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | ||
201 | ScriptErrorFilterStrategy testee; | 226 | ScriptErrorFilterStrategy testee; | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 311 | { | |||
297 | QCOMPARE(item.type , itemtype); | 322 | QCOMPARE(item.type , itemtype); | ||
298 | } | 323 | } | ||
299 | 324 | | |||
300 | void TestFilteringStrategy::testStaticAnalysisFilterStrategy_data() | 325 | void TestFilteringStrategy::testStaticAnalysisFilterStrategy_data() | ||
301 | { | 326 | { | ||
302 | QTest::addColumn<QString>("line"); | 327 | QTest::addColumn<QString>("line"); | ||
303 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | 328 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | ||
304 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | 329 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | ||
330 | QTest::addColumn<TestPathType>("pathType"); | ||||
305 | 331 | | |||
306 | QTest::newRow("cppcheck-info-line") | 332 | QTest::newRow("cppcheck-info-line") | ||
307 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 333 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
308 | QTest::newRow("cppcheck-error-line") | 334 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
309 | << buildCppCheckErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 335 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
310 | QTest::newRow("krazy2-error-line") | 336 | << buildCppCheckErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;; | ||
311 | << buildKrazyErrorLine() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 337 | QTest::newRowForPathType("krazy2-error-line", pathType) | ||
312 | QTest::newRow("krazy2-error-line-two-colons") | 338 | << buildKrazyErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
313 | << buildKrazyErrorLine2() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 339 | QTest::newRowForPathType("krazy2-error-line-two-colons", pathType) | ||
314 | QTest::newRow("krazy2-error-line-error-description") | 340 | << buildKrazyErrorLine2(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
315 | << buildKrazyErrorLine3() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 341 | QTest::newRowForPathType("krazy2-error-line-error-description", pathType) | ||
316 | QTest::newRow("krazy2-error-line-wo-line-info") | 342 | << buildKrazyErrorLine3(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
317 | << buildKrazyErrorLineNoLineInfo() << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 343 | QTest::newRowForPathType("krazy2-error-line-wo-line-info", pathType) | ||
318 | QTest::newRow("compiler-line") | 344 | << buildKrazyErrorLineNoLineInfo(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
319 | << buildCompilerLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 345 | QTest::newRowForPathType("compiler-line", pathType) | ||
320 | QTest::newRow("compiler-error-line") | 346 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
321 | << buildCompilerErrorLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 347 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
348 | << buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||||
349 | } | ||||
322 | QTest::newRow("compiler-action-line") | 350 | QTest::newRow("compiler-action-line") | ||
323 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 351 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
324 | QTest::newRow("python-error-line") | 352 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
325 | << buildPythonErrorLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; | 353 | QTest::newRowForPathType("python-error-line", pathType) | ||
354 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||||
355 | } | ||||
326 | } | 356 | } | ||
327 | 357 | | |||
328 | void TestFilteringStrategy::testStaticAnalysisFilterStrategy() | 358 | void TestFilteringStrategy::testStaticAnalysisFilterStrategy() | ||
329 | { | 359 | { | ||
330 | // Test that url's are extracted correctly as well | | |||
331 | QString referencePath = projectPath() + "main.cpp"; | | |||
332 | | ||||
333 | QFETCH(QString, line); | 360 | QFETCH(QString, line); | ||
334 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | 361 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | ||
335 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | 362 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | ||
363 | QFETCH(TestPathType, pathType); | ||||
364 | | ||||
365 | // Test that url's are extracted correctly as well | ||||
366 | QString referencePath = projectPath(pathType) + "main.cpp"; | ||||
367 | | ||||
336 | StaticAnalysisFilterStrategy testee; | 368 | StaticAnalysisFilterStrategy testee; | ||
337 | FilteredItem item1 = testee.errorInLine(line); | 369 | FilteredItem item1 = testee.errorInLine(line); | ||
338 | QString extractedPath = item1.url.toLocalFile(); | 370 | QString extractedPath = item1.url.toLocalFile(); | ||
339 | QVERIFY((item1.type != FilteredItem::ErrorItem) || ( extractedPath == referencePath)); | 371 | QVERIFY((item1.type != FilteredItem::ErrorItem) || ( extractedPath == referencePath)); | ||
340 | QCOMPARE(item1.type, expectedError); | 372 | QCOMPARE(item1.type, expectedError); | ||
341 | item1 = testee.actionInLine(line); | 373 | item1 = testee.actionInLine(line); | ||
342 | QCOMPARE(item1.type, expectedAction); | 374 | QCOMPARE(item1.type, expectedAction); | ||
343 | } | 375 | } | ||
344 | 376 | | |||
345 | void TestFilteringStrategy::testCompilerFilterstrategyUrlFromAction_data() | 377 | void TestFilteringStrategy::testCompilerFilterstrategyUrlFromAction_data() | ||
346 | { | 378 | { | ||
347 | QTest::addColumn<QString>("line"); | 379 | QTest::addColumn<QString>("line"); | ||
348 | QTest::addColumn<QString>("expectedLastDir"); | 380 | QTest::addColumn<QString>("expectedLastDir"); | ||
349 | QString basepath = projectPath(); | 381 | QTest::addColumn<TestPathType>("pathType"); | ||
350 | 382 | | |||
351 | QTest::newRow("cmake-line1") | 383 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | ||
352 | << "[ 25%] Building CXX object path/to/one/CMakeFiles/file.o" << QString( basepath + "/path/to/one" ); | 384 | const QString basepath = projectPath(pathType); | ||
353 | QTest::newRow("cmake-line2") | 385 | | ||
354 | << "[ 26%] Building CXX object path/to/two/CMakeFiles/file.o" << QString( basepath + "/path/to/two"); | 386 | QTest::newRowForPathType("cmake-line1", pathType) | ||
355 | QTest::newRow("cmake-line3") | 387 | << "[ 25%] Building CXX object path/to/one/CMakeFiles/file.o" << QString( basepath + "/path/to/one" ) << pathType; | ||
356 | << "[ 26%] Building CXX object path/to/three/CMakeFiles/file.o" << QString( basepath + "/path/to/three"); | 388 | QTest::newRowForPathType("cmake-line2", pathType) | ||
357 | QTest::newRow("cmake-line4") | 389 | << "[ 26%] Building CXX object path/to/two/CMakeFiles/file.o" << QString( basepath + "/path/to/two") << pathType; | ||
358 | << "[ 26%] Building CXX object path/to/four/CMakeFiles/file.o" << QString( basepath + "/path/to/four"); | 390 | QTest::newRowForPathType("cmake-line3", pathType) | ||
359 | QTest::newRow("cmake-line5") | 391 | << "[ 26%] Building CXX object path/to/three/CMakeFiles/file.o" << QString( basepath + "/path/to/three") << pathType; | ||
360 | << "[ 26%] Building CXX object path/to/two/CMakeFiles/file.o" << QString( basepath + "/path/to/two"); | 392 | QTest::newRowForPathType("cmake-line4", pathType) | ||
361 | QTest::newRow("cd-line6") | 393 | << "[ 26%] Building CXX object path/to/four/CMakeFiles/file.o" << QString( basepath + "/path/to/four") << pathType; | ||
362 | << QString("make[4]: Entering directory '" + basepath + "/path/to/one/'") << QString( basepath + "/path/to/one"); | 394 | QTest::newRowForPathType("cmake-line5", pathType) | ||
363 | QTest::newRow("waf-cd") | 395 | << "[ 26%] Building CXX object path/to/two/CMakeFiles/file.o" << QString( basepath + "/path/to/two") << pathType; | ||
364 | << QString("Waf: Entering directory `" + basepath + "/path/to/two/'") << QString( basepath + "/path/to/two"); | 396 | QTest::newRowForPathType("cd-line6", pathType) | ||
365 | QTest::newRow("cmake-line7") | 397 | << QString("make[4]: Entering directory '" + basepath + "/path/to/one/'") << QString( basepath + "/path/to/one") << pathType; | ||
366 | << QStringLiteral("[ 50%] Building CXX object CMakeFiles/testdeque.dir/RingBuffer.cpp.o") << QString( basepath); | 398 | QTest::newRowForPathType("waf-cd", pathType) | ||
399 | << QString("Waf: Entering directory `" + basepath + "/path/to/two/'") << QString( basepath + "/path/to/two") << pathType; | ||||
400 | QTest::newRowForPathType("cmake-line7", pathType) | ||||
401 | << QStringLiteral("[ 50%] Building CXX object CMakeFiles/testdeque.dir/RingBuffer.cpp.o") << QString( basepath) << pathType; | ||||
402 | } | ||||
367 | } | 403 | } | ||
368 | 404 | | |||
369 | void TestFilteringStrategy::testCompilerFilterstrategyUrlFromAction() | 405 | void TestFilteringStrategy::testCompilerFilterstrategyUrlFromAction() | ||
370 | { | 406 | { | ||
371 | QFETCH(QString, line); | 407 | QFETCH(QString, line); | ||
372 | QFETCH(QString, expectedLastDir); | 408 | QFETCH(QString, expectedLastDir); | ||
373 | QUrl projecturl = QUrl::fromLocalFile( projectPath() ); | 409 | QFETCH(TestPathType, pathType); | ||
374 | static CompilerFilterStrategy testee(projecturl); | 410 | | ||
411 | QUrl projecturl = QUrl::fromLocalFile( projectPath(pathType) ); | ||||
412 | CompilerFilterStrategy testee(projecturl); | ||||
375 | FilteredItem item1 = testee.actionInLine(line); | 413 | FilteredItem item1 = testee.actionInLine(line); | ||
376 | int last = testee.getCurrentDirs().size() - 1; | 414 | int last = testee.getCurrentDirs().size() - 1; | ||
377 | QCOMPARE(testee.getCurrentDirs().at(last), expectedLastDir); | 415 | QCOMPARE(testee.getCurrentDirs().at(last), expectedLastDir); | ||
378 | } | 416 | } | ||
379 | 417 | | |||
380 | void TestFilteringStrategy::benchMarkCompilerFilterAction() | 418 | void TestFilteringStrategy::benchMarkCompilerFilterAction() | ||
381 | { | 419 | { | ||
382 | QString projecturl = projectPath(); | 420 | QString projecturl = projectPath(); | ||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |