Skip to content
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
7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
<configuration>
<additionalJOptions>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</additionalJOption>
</additionalJOptions>
</configuration>
Expand Down Expand Up @@ -253,11 +256,11 @@
<properties>
<test.jvm.flags>
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
</test.jvm.flags>
</properties>
</profile>
Expand Down
53 changes: 24 additions & 29 deletions src/main/java/com/google/testing/compile/CompileTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

import com.google.common.io.ByteSource;
import com.google.errorprone.annotations.CanIgnoreReturnValue;

import java.nio.charset.Charset;

import javax.tools.Diagnostic;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
Expand All @@ -44,8 +42,7 @@ public interface CompileTester {
SuccessfulCompilationClause compilesWithoutError();

/**
* The clause in the fluent API that tests for successful compilation without warnings or
* errors.
* The clause in the fluent API that tests for successful compilation without warnings or errors.
*/
@CanIgnoreReturnValue
CleanCompilationClause compilesWithoutWarnings();
Expand All @@ -57,7 +54,7 @@ public interface CompileTester {
/**
* The clause in the fluent API that allows for chaining test conditions.
*
* @param T the clause type returned by {@link #and()}
* @param <T> the clause type returned by {@link #and()}
*/
public interface ChainingClause<T> {
T and();
Expand All @@ -66,12 +63,12 @@ public interface ChainingClause<T> {
/**
* The clause in the fluent API that checks notes in a compilation.
*
* @param T the non-generic clause type implementing this interface
* @param <T> the non-generic clause type implementing this interface
*/
public interface CompilationWithNotesClause<T> {
/**
* Checks that a note exists that contains the given fragment in the
* {@linkplain Diagnostic#getMessage(java.util.Locale) diagnostic message}.
* Checks that a note exists that contains the given fragment in the {@linkplain
* Diagnostic#getMessage(java.util.Locale) diagnostic message}.
*/
@CanIgnoreReturnValue
FileClause<T> withNoteContaining(String messageFragment);
Expand All @@ -87,13 +84,13 @@ public interface CompilationWithNotesClause<T> {
/**
* The clause in the fluent API that checks notes and warnings in a compilation.
*
* @param T the non-generic clause type implementing this interface
* @param <T> the non-generic clause type implementing this interface
*/
public interface CompilationWithWarningsClause<T> extends CompilationWithNotesClause<T> {

/**
* Checks that a warning exists that contains the given fragment in the
* {@linkplain Diagnostic#getMessage(java.util.Locale) diagnostic message}.
* Checks that a warning exists that contains the given fragment in the {@linkplain
* Diagnostic#getMessage(java.util.Locale) diagnostic message}.
*/
@CanIgnoreReturnValue
FileClause<T> withWarningContaining(String messageFragment);
Expand All @@ -110,29 +107,29 @@ public interface CompilationWithWarningsClause<T> extends CompilationWithNotesCl
* The clause in the fluent API that checks that a diagnostic is associated with a particular
* {@link JavaFileObject}.
*
* @param T the clause type returned by {@link ChainingClause#and()}
* @param <T> the clause type returned by {@link ChainingClause#and()}
*/
public interface FileClause<T> extends ChainingClause<T> {
@CanIgnoreReturnValue
LineClause<T> in(JavaFileObject file);
}

/**
* The clause in the fluent API that checks that a diagnostic is on a particular
* {@linkplain Diagnostic#getLineNumber() line}.
* The clause in the fluent API that checks that a diagnostic is on a particular {@linkplain
* Diagnostic#getLineNumber() line}.
*
* @param T the clause type returned by {@link ChainingClause#and()}
* @param <T> the clause type returned by {@link ChainingClause#and()}
*/
public interface LineClause<T> extends ChainingClause<T> {
@CanIgnoreReturnValue
ColumnClause<T> onLine(long lineNumber);
}

/**
* The clause in the fluent API that checks that a diagnostic starts at a particular
* {@linkplain Diagnostic#getColumnNumber() column}.
* The clause in the fluent API that checks that a diagnostic starts at a particular {@linkplain
* Diagnostic#getColumnNumber() column}.
*
* @param T the clause type returned by {@link ChainingClause#and()}
* @param <T> the clause type returned by {@link ChainingClause#and()}
*/
public interface ColumnClause<T> extends ChainingClause<T> {
@CanIgnoreReturnValue
Expand All @@ -142,12 +139,12 @@ public interface ColumnClause<T> extends ChainingClause<T> {
/**
* The clause in the fluent API that checks that files were generated.
*
* @param T the non-generic clause type implementing this interface
* @param <T> the non-generic clause type implementing this interface
*/
public interface GeneratedPredicateClause<T> {
/**
* Checks that a source file with an equivalent
* <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a> was generated for each of
* Checks that a source file with an equivalent <a
* href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a> was generated for each of
* the given {@linkplain JavaFileObject files}.
*/
@CanIgnoreReturnValue
Expand All @@ -160,9 +157,7 @@ public interface GeneratedPredicateClause<T> {
@CanIgnoreReturnValue
T generatesFiles(JavaFileObject first, JavaFileObject... rest);

/**
* Checks that a file with the specified location, package, and filename was generated.
*/
/** Checks that a file with the specified location, package, and filename was generated. */
@CanIgnoreReturnValue
SuccessfulFileClause<T> generatesFileNamed(
JavaFileManager.Location location, String packageName, String relativeName);
Expand All @@ -171,12 +166,12 @@ SuccessfulFileClause<T> generatesFileNamed(
/**
* The clause in the fluent API that checks that a generated file has the specified contents.
*
* @param T the non-generic clause type implementing this interface
* @param <T> the non-generic clause type implementing this interface
*/
public interface SuccessfulFileClause<T> extends ChainingClause<GeneratedPredicateClause<T>> {
/**
* Checks that the contents of the generated file match the contents of the specified
* {@link ByteSource}.
* Checks that the contents of the generated file match the contents of the specified {@link
* ByteSource}.
*/
@CanIgnoreReturnValue
SuccessfulFileClause<T> withContents(ByteSource expectedByteSource);
Expand All @@ -203,8 +198,8 @@ public interface CleanCompilationClause
public interface UnsuccessfulCompilationClause
extends CompilationWithWarningsClause<UnsuccessfulCompilationClause> {
/**
* Checks that an error exists that contains the given fragment in the
* {@linkplain Diagnostic#getMessage(java.util.Locale) diagnostic message}.
* Checks that an error exists that contains the given fragment in the {@linkplain
* Diagnostic#getMessage(java.util.Locale) diagnostic message}.
*/
@CanIgnoreReturnValue
FileClause<UnsuccessfulCompilationClause> withErrorContaining(String messageFragment);
Expand Down