Skip to content

Commit 9b68efb

Browse files
authored
Update documentation in AbstractCompilersProvider.java
Improve documentation around internal behaviours and expectations. Signed-off-by: ascopes <[email protected]>
1 parent e1baf30 commit 9b68efb

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/junit/AbstractCompilersProvider.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,37 @@
3131
import org.junit.jupiter.api.extension.ExtensionContext;
3232
import org.junit.jupiter.params.provider.Arguments;
3333
import org.junit.jupiter.params.provider.ArgumentsProvider;
34+
import org.junit.jupiter.params.support.AnnotationConsumer;
3435
import org.opentest4j.TestAbortedException;
3536

3637
/**
3738
* Base for defining a compiler-supplying arguments-provider for JUnit Jupiter parameterised test
3839
* support.
3940
*
41+
* <p>Each implementation is expected to provide:
42+
*
43+
* <ul>
44+
* <li>A method {@link #initializeNewCompiler} that returns new instances of a
45+
* {@link JctCompiler};</li>
46+
* <li>A minimum acceptable language level for the compiler, as an integer;</li>
47+
* <li>A maximum acceptable language level for the compiler, as an integer;</li>
48+
* <li>An implementation of {@link AnnotationConsumer} that consumes the desired
49+
* annotation. The details of the annotation should be extracted and a call
50+
* to {@link #configure} should be made.</li>
51+
* </ul>
52+
*
4053
* <p>An example annotation would look like the following:
4154
*
4255
* <pre><code>
4356
* {@literal @ArgumentsSource(MyCompilersProvider.class)}
4457
* {@literal @ParameterizedTest(name = "for {0}")}
4558
* {@literal @Retention(RetentionPolicy.RUNTIME)}
59+
* {@literal @Tag("java-compiler-testing-test")}
4660
* {@literal @Target}({
4761
* ElementType.ANNOTATION_TYPE,
4862
* ElementType.METHOD,
49-
* ElementType.TYPE,
5063
* })
64+
* {@literal @TestTemplate}
5165
* public {@literal @interface} MyCompilerTest {
5266
* int minVersion() default Integer.MIN_VALUE;
5367
* int maxVersion() default Integer.MAX_VALUE;
@@ -89,8 +103,8 @@
89103
* }
90104
* }
91105
* </code></pre>
92-
* <p>
93-
* This would enable you to define your test cases like so:
106+
*
107+
* <p>This would enable you to define your test cases like so:
94108
*
95109
* <pre><code>
96110
* {@literal @MyCompilerTest(minVersion=13, maxVersion=17)}
@@ -151,6 +165,20 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
151165
/**
152166
* Configure this provider with parameters from annotations.
153167
*
168+
* <p>This is expected to be called from an implementation of {@link AnnotationConsumer}.
169+
*
170+
* <p>The minimum compiler version will be set to the {@code min} parameter, or {@link #minSupportedVersion},
171+
* whichever is greater. This means annotations can pass {@link Integer#MIN_VALUE} as a default value safely.
172+
*
173+
* <p>The maximum compiler version will be set to the {@code max} parameter, or {@link #maxSupportedVersion},
174+
* whichever is smaller. This means annotations can pass {@link Integer#MAC_VALUE} as a default value safely.
175+
*
176+
* <p>If implementations do not support specifying custom compiler configurers, then an empty array must be
177+
* passed for the {@code configurerClasses} parameter.
178+
*
179+
* <p>If implementations do not support changing the version strategy, then it is suggested to pass
180+
* {@link VersionStrategy#RELEASE} as the value for the {@code versionStrategy} parameter.
181+
*
154182
* @param min the inclusive minimum compiler version to use.
155183
* @param max the inclusive maximum compiler version to use.
156184
* @param configurerClasses the configurer classes to apply to each compiler.

0 commit comments

Comments
 (0)