/** * Parses a file with two Intel warnings. * * @throws IOException if the file could not be read */ @Test public void testWarningsParser() throws IOException { Collection<FileAnnotation> warnings = new IntelCParser().parse(openFile()); assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 4, warnings.size()); Iterator<FileAnnotation> iterator = warnings.iterator(); FileAnnotation annotation = iterator.next(); checkWarning( annotation, 1460, "LOOP WAS VECTORIZED.", "D:/Hudson/workspace/foo/busdates.cpp", TYPE, "Remark", Priority.LOW); annotation = iterator.next(); // remark checkWarning( annotation, 2630, "FUSED LOOP WAS VECTORIZED.", "D:/Hudson/workspace/foo/hols.cpp", TYPE, "Remark", Priority.LOW); annotation = iterator.next(); checkWarning( annotation, 721, "last line of file ends without a newline", "D:/Hudson/workspace/zoo/oppdend2d_slv_strip_utils.cpp", TYPE, "Remark #1", Priority.LOW); annotation = iterator.next(); checkWarning( annotation, 17, "external function definition with no prior declaration", "D:/Hudson/workspace/boo/serviceif.cpp", TYPE, "Remark #1418", Priority.LOW); }
/** * Parses a warning log with 3 warnings. * * @throws IOException if the file could not be read * @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-5402">Issue 5402</a> */ @Test public void issue5402() throws IOException { Collection<FileAnnotation> warnings = new IntelCParser().parse(openFile("issue5402.txt")); assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 4, warnings.size()); Iterator<FileAnnotation> iterator = warnings.iterator(); checkWarning( iterator.next(), 980, "label \"find_rule\" was declared but never referenced", "<stdout>", TYPE, "Warning #177", Priority.NORMAL); checkWarning( iterator.next(), 2454, "function \"yy_flex_strlen\" was declared but never referenced", "<stdout>", TYPE, "Warning #177", Priority.NORMAL); checkWarning( iterator.next(), 120, "function \"fopen\" (declared at line 237 of \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\INCLUDE\\stdio.h\") was declared \"deprecated (\"This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.\") \"", "D:/hudson/workspace/continuous-snext-main-Win32/trunk/src/engine/AllocationProfiler.cpp", TYPE, "Warning #1786", Priority.NORMAL); checkWarning( iterator.next(), 120, "function \"fopen\" (declared at line 237 of \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\INCLUDE\\stdio.h\") was declared \"deprecated (\"This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.\") \"", "D:/hudson/workspace/continuous-snext-main-Win32/trunk/src/engine/AllocationProfiler.cpp", TYPE, "Error #1786", Priority.HIGH); }
/** * Parses a file with 8 warnings. * * @throws IOException if the file could not be read */ @Test public void parseSunCpp() throws IOException { Collection<FileAnnotation> warnings = new SunCParser().parse(openFile()); assertEquals("Wrong number of warnings detected.", 8, warnings.size()); Iterator<FileAnnotation> iterator = warnings.iterator(); FileAnnotation annotation = iterator.next(); checkWarning(annotation, 212, MESSAGE, "usi_plugin.cpp", TYPE, CATEGORY, Priority.NORMAL); annotation = iterator.next(); checkWarning( annotation, 224, "String literal converted to char* in formal argument msg in call to except(char*).", "usi_plugin.cpp", TYPE, CATEGORY, Priority.NORMAL); annotation = iterator.next(); checkWarning(annotation, 8, MESSAGE, "ServerList.cpp", TYPE, "", Priority.HIGH); annotation = iterator.next(); checkWarning(annotation, 44, MESSAGE, "ServerList.cpp", TYPE, CATEGORY, Priority.NORMAL); annotation = iterator.next(); checkWarning(annotation, 50, MESSAGE, "ServerList.cpp", TYPE, CATEGORY, Priority.NORMAL); annotation = iterator.next(); checkWarning( annotation, 19, "Child::operator== hides the function Parent::operator==(Parent&) const.", "warner.cpp", TYPE, "hidef", Priority.NORMAL); annotation = iterator.next(); checkWarning( annotation, 30, "Assigning void(*)(int) to extern \"C\" void(*)(int).", "warner.cpp", TYPE, "wbadlkgasg", Priority.NORMAL); annotation = iterator.next(); // test warning where -errtags=yes was not used checkWarning( annotation, 32, "statement is unreachable.", "warner.cpp", TYPE, "", Priority.NORMAL); }
/** * Parses a file with warnings of the Reshaper InspectCodeParser tools. * * @throws IOException if the file could not be read */ @Test public void parseWarnings() throws IOException { Collection<FileAnnotation> warnings = new ReshaperInspectCodeParser().parse(openFile()); assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 1, warnings.size()); Iterator<FileAnnotation> iterator = warnings.iterator(); FileAnnotation annotation = iterator.next(); checkWarning( annotation, 4, "Using directive is not required by the code and can be safely removed", "euler61/Program.cs", "ReshaperInspectCode", "RedundantUsingDirective", Priority.NORMAL); }