Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Move GitHub issue to correct package and fix problem with multiple @Test annotations #5234

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Guidelines for feature pull-requests:
Other kinds of pull-requests:

1. Pull requests with passing test cases only are welcome, they specify previously unspecified behavior and are prefixed by "test:".
1. Pull requests with failing test cases only are welcome, they reproduce bugs and are very useful for maintainers to fix them. You can prevent failing the CI with adding the annotation `@GitHubIssue(issueNumber = <your-issue-number>, fixed = false)`. If you fix a test case with such an annotation mark the test case as fixed with `@GitHubIssue(issueNumber = <your-issue-number>, fixed = true)`.
2. Pull requests with failing test cases only are welcome, they reproduce bugs and are very useful for maintainers to fix them. You can prevent failing the CI with adding the annotation `@GitHubIssue(issueNumber = <your-issue-number>, fixed = false)`. If you fix a test case with such an annotation mark the test case as fixed with `@GitHubIssue(issueNumber = <your-issue-number>, fixed = true)`.
1. "Chore" pull-requests modify the CI setup.
1. If there is no activity on an issue or on a pull request for 3 months it's closed.

Expand Down
5 changes: 3 additions & 2 deletions src/test/java/spoon/reflect/factory/PackageFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Test;
import spoon.Launcher;
import spoon.reflect.declaration.CtPackage;
import spoon.test.GitHubIssue;
import spoon.testing.utils.GitHubIssue;

class PackageFactoryTest {

@Test
@GitHubIssue(issueNumber = 4764, fixed = true)
void getOrCreate_returnsNestedPackageStructure_whenQualifiedNameRepeatsSimpleName() {
// contract: A qualified name that is simply repetitions of a single simple name results in the expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.reflect.reference.CtArrayTypeReferenceImpl;
import spoon.test.GitHubIssue;
import spoon.test.SpoonTestHelpers;
import spoon.testing.utils.GitHubIssue;
import spoon.testing.utils.ModelTest;

import java.io.FileNotFoundException;
Expand Down Expand Up @@ -271,6 +271,7 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo

@Nested
class SquareBracketsForArrayInitialization_ArrayIsBuiltUsingFactoryMethods {
@Test
@GitHubIssue(issueNumber = 4887, fixed = true)
void bracketsShouldBeAttachedToTypeByDefault() {
// contract: the square brackets should be attached to type by default when array is built using factory methods
Expand Down Expand Up @@ -333,6 +334,7 @@ void testKeepGenericType(Factory factory) {
assertThat(printed, containsRegexMatch("List<.*List<\\? super T>>"));
}

@Test
@GitHubIssue(issueNumber = 4881, fixed = true)
void bracketsShouldBeMinimallyPrintedForTypeCastOnFieldRead() throws FileNotFoundException {
// contract: the brackets should be minimally printed for type cast on field read
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/spoon/support/TypeAdaptorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.adaption.TypeAdaptor;
import spoon.test.GitHubIssue;
import spoon.testing.utils.GitHubIssue;
import spoon.testing.utils.ModelTest;

import java.util.List;
Expand Down Expand Up @@ -444,6 +444,7 @@ public <T extends CharSequence> void overloaded(T t) {}
public <T extends String> void overriden(T t) {}
}

@Test
@GitHubIssue(issueNumber = 5226, fixed = true)
void testAdaptingTypeFromEnclosingClass() {
Launcher launcher = new Launcher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@
import spoon.support.util.compilation.JavacFacade;
import spoon.support.visitor.equals.EqualsChecker;
import spoon.support.visitor.equals.EqualsVisitor;
import spoon.test.GitHubIssue;
import spoon.test.generics.testclasses3.ComparableComparatorBug;
import spoon.test.innerclasses.InnerClasses;
import spoon.test.pkg.PackageTest;
import spoon.test.pkg.cyclic.Outside;
import spoon.test.pkg.cyclic.direct.Cyclic;
import spoon.test.pkg.cyclic.indirect.Indirect;
import spoon.testing.utils.GitHubIssue;

public class JavaReflectionTreeBuilderTest {

Expand Down Expand Up @@ -850,6 +850,7 @@ void testInnerClassesConstructorParameters() {
assertThat(asClass.getConstructors().iterator().next().getParameters().size(), equalTo(inners.size()));
}

@Test
@GitHubIssue(issueNumber = 4972, fixed = true)
void parameterNamesAreParsedWhenCompilingWithParametersFlag() throws ClassNotFoundException {
ClassLoader loader = JavacFacade.compileFiles(
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/comment/CommentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import spoon.support.StandardEnvironment;
import spoon.support.compiler.jdt.JDTSnippetCompiler;
import spoon.support.reflect.code.CtCommentImpl;
import spoon.test.GitHubIssue;
import spoon.test.comment.testclasses.BlockComment;
import spoon.test.comment.testclasses.Comment1;
import spoon.test.comment.testclasses.Comment2;
Expand All @@ -87,6 +86,7 @@
import spoon.test.comment.testclasses.TestClassWithComments;
import spoon.test.comment.testclasses.WildComments;
import spoon.test.comment.testclasses.WindowsEOL;
import spoon.testing.utils.GitHubIssue;
import spoon.testing.utils.LineSeparatorExtension;
import spoon.testing.utils.ModelTest;

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/spoon/test/enums/EnumsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.reflect.CtExtendedModifier;
import spoon.test.GitHubIssue;
import spoon.test.SpoonTestHelpers;
import spoon.test.annotation.AnnotationTest;
import spoon.test.enums.testclasses.Burritos;
import spoon.test.enums.testclasses.EnumWithMembers;
import spoon.test.enums.testclasses.NestedEnums;
import spoon.test.enums.testclasses.Regular;
import spoon.testing.utils.GitHubIssue;
import spoon.testing.utils.ModelUtils;

import java.io.File;
Expand Down Expand Up @@ -286,6 +286,7 @@ void testLocalEnumExists() {
));
}

@Test
@GitHubIssue(issueNumber = 4758, fixed = true)
@DisplayName("Implicit enum constructors do not contain a super call")
void testImplicitEnumConstructorSuperCall() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/spoon/test/factory/CodeFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.util.compilation.JavacFacade;
import spoon.test.GitHubIssue;

import spoon.testing.utils.GitHubIssue;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -66,8 +65,9 @@ public void testCreateVariableAssignement() {
assertEquals(f.getReference(), ((CtVariableWrite) va.getAssigned()).getVariable());
}

@Test
@GitHubIssue(issueNumber= 4956, fixed = true)
void createCtCatcVariablehWithoutModifiers() {
void createCtCatchVariableWithoutModifiers() {
// contract: CtCatchVariable without modifiers is created. This a test for the regression of #4940
Factory factory = createFactory();
CtTypeReference<Exception> exceptionType = factory.Type().createReference(Exception.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package spoon.test.issue3321;

import spoon.test.GitHubIssue;
import spoon.reflect.cu.SourcePosition;
import spoon.Launcher;
import spoon.reflect.factory.Factory;
import spoon.test.issue3321.testclasses.AnnoUser;
import spoon.testing.utils.GitHubIssue;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtMethod;

import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class AnnotationPositionTest {


@Test
@GitHubIssue(issueNumber = 3358, fixed = false)
public void testUsageOfTypeAnnotationOnParameterInMethod() {
final Launcher launcher = new Launcher();
Expand Down Expand Up @@ -68,6 +69,7 @@ public void testUsageOfTypeAnnotationOnParameterInMethod() {
}


@Test
@GitHubIssue(issueNumber = 3358, fixed = false)
public void testSneakyAnnotationsOnParameters() {
final Launcher launcher = new Launcher();
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/spoon/test/literal/LiteralTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import spoon.reflect.declaration.CtType;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.factory.CodeFactory;
import spoon.test.GitHubIssue;
import spoon.test.literal.testclasses.Tacos;
import spoon.Launcher;
import spoon.reflect.code.LiteralBase;
import spoon.reflect.cu.SourcePosition;
import spoon.reflect.factory.TypeFactory;
import spoon.reflect.declaration.CtClass;
import org.junit.jupiter.api.Test;
import spoon.testing.utils.GitHubIssue;
import spoon.testing.utils.ModelTest;
import java.util.List;
import java.util.TreeSet;
Expand Down Expand Up @@ -260,6 +260,7 @@ public void testLiteralBasePrinter(Factory factory) {
assertEquals("\"hello\"", ctClass.getField("s1").getDefaultExpression().toString());
}

@Test
@GitHubIssue(issueNumber = 5070, fixed = true)
void tooStrictEscaping() {
// contract: inside a string without a position ' are not escaped.
Expand All @@ -272,6 +273,7 @@ void tooStrictEscaping() {
assertEquals("\"'\"", ctLiteral.toString());
}

@Test
@GitHubIssue(issueNumber = 5070, fixed = true)
void tooStrictEscapingCharTest() {
// contract: inside a string with a position ' are escaped.
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/spoon/test/logging/LogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.JavaOutputProcessor;
import spoon.support.Level;
import spoon.test.GitHubIssue;
import spoon.testing.utils.GitHubIssue;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
import java.util.List;
Expand Down Expand Up @@ -112,6 +112,7 @@ public void testLoggingOff() {
assertEquals(0, logger.getLoggingEvents().size());
}

@Test
@GitHubIssue(issueNumber = 4997, fixed = true)
void innerTypesCrashesLogging() {
// contract: when a class has inner types, the logging should not crash with a NPE
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/spoon/test/model/SwitchCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.compiler.VirtualFile;
import spoon.test.GitHubIssue;
import spoon.testing.utils.GitHubIssue;

@DisplayName("Switchcase Tests")
public class SwitchCaseTest {
Expand Down Expand Up @@ -233,6 +233,7 @@ public void testSwitchColons() {
);
}

@Test
@GitHubIssue(issueNumber = 4696, fixed = true)
void testVariableScopeInSwitch() {
// contract: different cases do not introduce different scopes in colon-switches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import org.apache.commons.io.FileUtils;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeAll;

import org.junit.jupiter.api.Test;
import spoon.Launcher;
import spoon.compiler.Environment;
import spoon.reflect.CtModel;
import spoon.reflect.code.CtComment.CommentType;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.sniper.SniperJavaPrettyPrinter;
import spoon.test.GitHubIssue;
import spoon.testing.utils.GitHubIssue;

public class SniperAnnotatedEnumTest {
private static final Path INPUT_PATH = Paths.get("src/test/java/");
Expand All @@ -29,6 +29,7 @@ public static void setup() throws IOException {
FileUtils.deleteDirectory(OUTPUT_PATH.toFile());
}

@Test
@GitHubIssue(issueNumber = 4779, fixed = true)
public void annotatedEnumTest() throws IOException {
runSniperJavaPrettyPrinter("spoon/test/prettyprinter/testclasses/AnnotatedEnum.java");
Expand Down
Loading