Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/outputview/tests/test_filteringstrategy.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | 69 | | |||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | void TestFilteringStrategy::testNoFilterStrategy_data() | 72 | void TestFilteringStrategy::testNoFilterStrategy_data() | ||
73 | { | 73 | { | ||
74 | QTest::addColumn<QString>("line"); | 74 | QTest::addColumn<QString>("line"); | ||
75 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected"); | 75 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected"); | ||
76 | 76 | | |||
77 | QTest::newRow("cppcheck-info-line") | 77 | for (TestPathType pathType : | ||
78 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem; | 78 | #ifdef Q_OS_WIN | ||
79 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | 79 | {WindowsFilePathNoSpaces, WindowsFilePathWithSpaces} | ||
80 | | ||||
81 | #else | ||||
82 | {UnixFilePathNoSpaces, UnixFilePathWithSpaces} | ||||
83 | #endif | ||||
84 | ) { | ||||
80 | QTest::newRowForPathType("cppcheck-error-line", pathType) | 85 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
81 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem; | 86 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem; | ||
82 | QTest::newRowForPathType("compiler-line", pathType) | 87 | QTest::newRowForPathType("compiler-line", pathType) | ||
83 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem; | 88 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem; | ||
84 | QTest::newRowForPathType("compiler-error-line", pathType) | 89 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
85 | << buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem; | 90 | << buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem; | ||
86 | } | | |||
87 | QTest::newRow("compiler-action-line") | | |||
88 | << buildCompilerActionLine() << FilteredItem::InvalidItem; | | |||
89 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | | |||
90 | QTest::newRowForPathType("compiler-information-line", pathType) | 91 | QTest::newRowForPathType("compiler-information-line", pathType) | ||
91 | << buildCompilerInformationLine(pathType) << FilteredItem::InvalidItem; | 92 | << buildCompilerInformationLine(pathType) << FilteredItem::InvalidItem; | ||
92 | QTest::newRowForPathType("python-error-line", pathType) | 93 | QTest::newRowForPathType("python-error-line", pathType) | ||
93 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem; | 94 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem; | ||
94 | } | 95 | } | ||
96 | QTest::newRow("cppcheck-info-line") | ||||
97 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem; | ||||
98 | QTest::newRow("compiler-action-line") | ||||
99 | << buildCompilerActionLine() << FilteredItem::InvalidItem; | ||||
95 | } | 100 | } | ||
96 | 101 | | |||
97 | void TestFilteringStrategy::testNoFilterStrategy() | 102 | void TestFilteringStrategy::testNoFilterStrategy() | ||
98 | { | 103 | { | ||
99 | QFETCH(QString, line); | 104 | QFETCH(QString, line); | ||
100 | QFETCH(FilteredItem::FilteredOutputItemType, expected); | 105 | QFETCH(FilteredItem::FilteredOutputItemType, expected); | ||
101 | NoFilterStrategy testee; | 106 | NoFilterStrategy testee; | ||
102 | FilteredItem item1 = testee.errorInLine(line); | 107 | FilteredItem item1 = testee.errorInLine(line); | ||
103 | QCOMPARE(item1.type, expected); | 108 | QCOMPARE(item1.type, expected); | ||
104 | item1 = testee.actionInLine(line); | 109 | item1 = testee.actionInLine(line); | ||
105 | QCOMPARE(item1.type, expected); | 110 | QCOMPARE(item1.type, expected); | ||
106 | } | 111 | } | ||
107 | 112 | | |||
108 | void TestFilteringStrategy::testCompilerFilterStrategy_data() | 113 | void TestFilteringStrategy::testCompilerFilterStrategy_data() | ||
109 | { | 114 | { | ||
110 | QTest::addColumn<QString>("line"); | 115 | QTest::addColumn<QString>("line"); | ||
111 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | 116 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedError"); | ||
112 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | 117 | QTest::addColumn<FilteredItem::FilteredOutputItemType>("expectedAction"); | ||
113 | QTest::addColumn<TestPathType>("pathType"); | 118 | QTest::addColumn<TestPathType>("pathType"); | ||
114 | 119 | | |||
115 | QTest::newRow("cppcheck-info-line") | 120 | QTest::newRow("cppcheck-info-line") | ||
116 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 121 | << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | ||
117 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | 122 | for (TestPathType pathType : | ||
123 | #ifdef Q_OS_WIN | ||||
124 | {WindowsFilePathNoSpaces, WindowsFilePathWithSpaces} | ||||
125 | #else | ||||
126 | {UnixFilePathNoSpaces, UnixFilePathWithSpaces} | ||||
127 | #endif | ||||
128 | ) { | ||||
118 | QTest::newRowForPathType("cppcheck-error-line", pathType) | 129 | QTest::newRowForPathType("cppcheck-error-line", pathType) | ||
119 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | 130 | << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
120 | QTest::newRowForPathType("compiler-line", pathType) | 131 | QTest::newRowForPathType("compiler-line", pathType) | ||
121 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | 132 | << buildCompilerLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
122 | QTest::newRowForPathType("compiler-error-line", pathType) | 133 | QTest::newRowForPathType("compiler-error-line", pathType) | ||
123 | << buildCompilerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | 134 | << buildCompilerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
124 | QTest::newRowForPathType("compiler-information-line", pathType) | 135 | QTest::newRowForPathType("compiler-information-line", pathType) | ||
125 | << buildCompilerInformationLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | 136 | << buildCompilerInformationLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
126 | QTest::newRowForPathType("compiler-information-line2", pathType) | 137 | QTest::newRowForPathType("compiler-information-line2", pathType) | ||
127 | << buildInfileIncludedFromFirstLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | 138 | << buildInfileIncludedFromFirstLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
128 | QTest::newRowForPathType("compiler-information-line3", pathType) | 139 | QTest::newRowForPathType("compiler-information-line3", pathType) | ||
129 | << buildInfileIncludedFromSecondLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | 140 | << buildInfileIncludedFromSecondLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
130 | } | | |||
131 | QTest::newRow("cmake-error-line1") | 141 | QTest::newRow("cmake-error-line1") | ||
132 | << "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 142 | << "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
133 | QTest::newRow("cmake-error-multiline1") | 143 | QTest::newRow("cmake-error-multiline1") | ||
134 | << "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 144 | << "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
135 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | | |||
136 | QTest::newRowForPathType("cmake-error-multiline2", pathType) | 145 | QTest::newRowForPathType("cmake-error-multiline2", pathType) | ||
137 | << buildCmakeConfigureMultiLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | 146 | << buildCmakeConfigureMultiLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
138 | } | 147 | QTest::newRowForPathType("cmake-warning-line", pathType) | ||
139 | QTest::newRow("cmake-warning-line") | 148 | << "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem << pathType; | ||
140 | << "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 149 | QTest::newRowForPathType("cmake-automoc-error", pathType) | ||
141 | QTest::newRow("cmake-automoc-error") | 150 | << buildAutoMocLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
142 | << "AUTOMOC: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 151 | QTest::newRowForPathType("cmake-automoc4-error", pathType) | ||
143 | QTest::newRow("cmake-automoc4-error") | 152 | << buildOldAutoMocLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; | ||
144 | << "automoc4: The file \"/foo/bar.cpp\" includes the moc file \"bar1.moc\"" << FilteredItem::InformationItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 153 | QTest::newRowForPathType("cmake-autogen-error", pathType) | ||
145 | QTest::newRow("cmake-autogen-error") | 154 | << buildAutoMocLine(pathType, false) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
146 | << "AUTOGEN: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; | 155 | QTest::newRowForPathType("linker-action-line", pathType) | ||
147 | QTest::newRow("linker-action-line") | 156 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem << pathType; | ||
148 | << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem << UnixFilePathNoSpaces; | | |||
149 | for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { | | |||
150 | QTest::newRowForPathType("linker-error-line", pathType) | 157 | QTest::newRowForPathType("linker-error-line", pathType) | ||
151 | << buildLinkerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | 158 | << buildLinkerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; | ||
152 | QTest::newRowForPathType("python-error-line", pathType) | 159 | QTest::newRowForPathType("python-error-line", pathType) | ||
153 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | 160 | << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; | ||
154 | } | 161 | } | ||
155 | } | 162 | } | ||
156 | 163 | | |||
157 | void TestFilteringStrategy::testCompilerFilterStrategy() | 164 | void TestFilteringStrategy::testCompilerFilterStrategy() | ||
Show All 28 Lines | 180 | { | |||
186 | << FilteredItem::WarningItem << FilteredItem::InvalidItem; | 193 | << FilteredItem::WarningItem << FilteredItem::InvalidItem; | ||
187 | QTest::newRow("error-in-filename-containing-warning-word") | 194 | QTest::newRow("error-in-filename-containing-warning-word") | ||
188 | << "WarningHandling.cpp:100:56: error: ‘Item’ was not declared in this scope" | 195 | << "WarningHandling.cpp:100:56: error: ‘Item’ was not declared in this scope" | ||
189 | << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | 196 | << FilteredItem::ErrorItem << FilteredItem::InvalidItem; | ||
190 | } | 197 | } | ||
191 | 198 | | |||
192 | void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords() | 199 | void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords() | ||
193 | { | 200 | { | ||
201 | #ifdef Q_OS_WIN | ||||
202 | TestPathType pathTypeToUse = WindowsFilePathNoSpaces; | ||||
203 | #else | ||||
204 | TestPathType pathTypeToUse = UnixFilePathNoSpaces; | ||||
205 | #endif | ||||
194 | QFETCH(QString, line); | 206 | QFETCH(QString, line); | ||
195 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | 207 | QFETCH(FilteredItem::FilteredOutputItemType, expectedError); | ||
196 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | 208 | QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); | ||
197 | QUrl projecturl = QUrl::fromLocalFile( projectPath() ); | 209 | QUrl projecturl = QUrl::fromLocalFile( projectPath(pathTypeToUse) ); | ||
198 | CompilerFilterStrategy testee(projecturl); | 210 | CompilerFilterStrategy testee(projecturl); | ||
199 | FilteredItem item1 = testee.errorInLine(line); | 211 | FilteredItem item1 = testee.errorInLine(line); | ||
200 | QCOMPARE(item1.type, expectedError); | 212 | QCOMPARE(item1.type, expectedError); | ||
201 | item1 = testee.actionInLine(line); | 213 | item1 = testee.actionInLine(line); | ||
202 | QCOMPARE(item1.type, expectedAction); | 214 | QCOMPARE(item1.type, expectedAction); | ||
203 | } | 215 | } | ||
204 | 216 | | |||
205 | void TestFilteringStrategy::testScriptErrorFilterStrategy_data() | 217 | void TestFilteringStrategy::testScriptErrorFilterStrategy_data() | ||
▲ Show 20 Lines • Show All 349 Lines • Show Last 20 Lines |