This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-14821]: Fixed equals method.
- Loading branch information
Showing
3 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 49 additions & 3 deletions
52
src/test/java/hudson/plugins/warnings/WarningsDifferencerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,65 @@ | ||
package hudson.plugins.warnings; | ||
|
||
import static junit.framework.Assert.*; | ||
import hudson.plugins.analysis.core.AnnotationDifferencer; | ||
import hudson.plugins.analysis.test.AnnotationDifferencerTest; | ||
import hudson.plugins.analysis.util.TreeString; | ||
import hudson.plugins.analysis.util.model.AbstractAnnotation; | ||
import hudson.plugins.analysis.util.model.FileAnnotation; | ||
import hudson.plugins.analysis.util.model.Priority; | ||
import hudson.plugins.warnings.parser.Gcc4CompilerParser; | ||
import hudson.plugins.warnings.parser.Warning; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
import org.junit.Test; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
|
||
/** | ||
* Tests the {@link AnnotationDifferencer} for warnings. | ||
*/ | ||
public class WarningsDifferencerTest extends AnnotationDifferencerTest { | ||
@Override | ||
public FileAnnotation createAnnotation(final String fileName, final Priority priority, final String message, final String category, | ||
final String type, final int start, final int end) { | ||
public FileAnnotation createAnnotation(final String fileName, final Priority priority, | ||
final String message, final String category, final String type, final int start, | ||
final int end) { | ||
return new Warning(fileName, start, type, category, message, priority); | ||
} | ||
} | ||
|
||
/** | ||
* Verifies that equals works with {@link TreeString} optimized path names. | ||
* | ||
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-14821">Issue 14821</a> | ||
*/ | ||
@Test | ||
public void testIssue14821() { | ||
Collection<FileAnnotation> first = parse(); | ||
Collection<FileAnnotation> second = parse(); | ||
|
||
assertEquals("Wrong number of warnings", 16, first.size()); | ||
assertEquals("Wrong number of warnings", 16, second.size()); | ||
|
||
AbstractAnnotation.intern(first); | ||
|
||
Set<FileAnnotation> newAnnotations = AnnotationDifferencer.getNewAnnotations(ImmutableSet.copyOf(first), ImmutableSet.copyOf(second)); | ||
assertEquals("Wrong number of new warnings", 0, newAnnotations.size()); | ||
Set<FileAnnotation> fixedAnnotations = AnnotationDifferencer.getFixedAnnotations(ImmutableSet.copyOf(first), ImmutableSet.copyOf(second)); | ||
assertEquals("Wrong number of fixed warnings", 0, fixedAnnotations.size()); | ||
} | ||
|
||
private Collection<FileAnnotation> parse() { | ||
try { | ||
InputStream inputStream = WarningsDifferencerTest.class .getResourceAsStream("issue14821.txt"); | ||
|
||
return new Gcc4CompilerParser().parse(new InputStreamReader(inputStream)); | ||
} | ||
catch (IOException exception) { | ||
throw new IllegalArgumentException(exception); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
main.c: In function "main": | ||
main.c:2:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main2.c: In function "main": | ||
main2.c:2:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main2.c: In function "main": | ||
main2.c:3:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main2.c: In function "main": | ||
main2.c:4:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main.c: In function "main": | ||
main.c:3:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main.c: In function "main": | ||
main.c:4:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main.c: In function "main": | ||
main.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main2.c: In function "main": | ||
main2.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main3.c: In function "main": | ||
main3.c:2:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main4.c: In function "main": | ||
main4.c:2:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main4.c: In function "main": | ||
main4.c:3:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main4.c: In function "main": | ||
main4.c:4:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main3.c: In function "main": | ||
main3.c:3:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main3.c: In function "main": | ||
main3.c:4:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main3.c: In function "main": | ||
main3.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] | ||
main4.c: In function "main": | ||
main4.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] |