public abstract class CheckerTest
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
checkerDir
The relative path to the directory containing test inputs.
|
protected java.lang.String |
checkerName
The fully-qualified class name of the checker to use for tests.
|
protected java.util.List<java.lang.String> |
checkerOptions
Extra options to pass to javac when running the checker.
|
Constructor and Description |
---|
CheckerTest(java.lang.Class<? extends javax.annotation.processing.AbstractProcessor> checker,
java.lang.String checkerDir,
java.lang.String... checkerOptions)
Creates a new checker test.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
assertDiagnostics(@ReadOnly java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> actualDiagnostics,
@ReadOnly java.io.File expectedDiagnosticFile,
java.lang.String javaFile,
java.util.List<java.lang.String> checkerOptions)
Compares the result of the compiler against a list of errors in a file.
|
protected static void |
assertDiagnostics(java.lang.String msg,
@ReadOnly java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> actual_diagnostics,
java.util.List<java.lang.String> expected_diagnostics,
java.lang.String filename,
java.util.List<java.lang.String> checkerOptions)
Compares the result of the compiler against an array of Strings.
|
protected static java.lang.String |
assertFailure(@ReadOnly TestRun run)
Asserts that the test compilation did not complete successfully.
|
protected static java.lang.String |
assertSuccess(@ReadOnly TestRun run)
Asserts that the test compilation completed without failures or
exceptions.
|
protected static void |
checkTestResult(TestRun run,
java.io.File expectedFile,
boolean shouldSucceed,
java.lang.String javaFile,
java.util.List<java.lang.String> checkerOptions) |
protected static void |
checkTestResult(TestRun run,
java.util.List<java.lang.String> expectedErrors,
boolean shouldSucceed,
java.lang.String javaFile,
java.util.List<java.lang.String> checkerOptions) |
protected TestRun |
getTest(java.io.File... files)
Compiles and returns a TestRun.
|
protected TestRun |
getTest(java.lang.String... files)
Compiles and returns a TestRun.
|
static java.lang.String |
join(java.lang.Object[] a,
java.lang.String delim)
Concatenate the string representations of the objects, placing the
delimiter between them.
|
static java.lang.String |
joinPrefixed(java.lang.Object[] a,
java.lang.String delim,
java.lang.String prefix)
Like join, but prefix each string by the given prefix.
|
protected void |
runTest(java.io.File expectedFile,
boolean shouldSucceed,
java.io.File... javaFiles) |
protected void |
runTest(java.io.File expectedFile,
java.io.File... javaFiles)
Tests that the result of compiling the javaFile matches the expectedFile.
|
protected void |
runTest(java.util.List<java.lang.String> expectedErrors,
boolean shouldSucceed,
java.lang.String... javaFiles) |
protected void |
runTest(java.lang.String expectedFileName,
boolean shouldSucceed,
java.io.File... javaFiles)
Tests that the result of compiling the javaFile matches the expectedFile.
|
protected void |
test() |
protected void |
test(java.io.File testFile)
Runs a test.
|
protected static void |
test(java.lang.String checkerName,
java.util.List<java.lang.String> checkerOptions,
java.io.File... javaFiles) |
protected final java.lang.String checkerName
protected final java.lang.String checkerDir
protected final java.util.List<java.lang.String> checkerOptions
public CheckerTest(java.lang.Class<? extends javax.annotation.processing.AbstractProcessor> checker, java.lang.String checkerDir, java.lang.String... checkerOptions)
checker
- the class for the checker to usecheckerDir
- the path to the directory of test inputscheckerOptions
- options to pass to the compiler when running testsprotected void test(java.io.File testFile)
runTest(java.io.File, java.io.File...)
-- if the calling method is
named testZZZ, this method uses an expected outfile called "ZZZ.out"
and a Java source file called "ZZZ.java".protected void test()
protected TestRun getTest(java.lang.String... files)
protected TestRun getTest(java.io.File... files)
protected void runTest(java.io.File expectedFile, java.io.File... javaFiles)
expectedFile
- the expected result for compilationjavaFiles
- the Java files to be compiledprotected static void test(java.lang.String checkerName, java.util.List<java.lang.String> checkerOptions, java.io.File... javaFiles)
protected void runTest(java.util.List<java.lang.String> expectedErrors, boolean shouldSucceed, java.lang.String... javaFiles)
protected void runTest(java.lang.String expectedFileName, boolean shouldSucceed, java.io.File... javaFiles)
expectedFileName
- the expected result for compilationshouldSucceed
- whether the javaFile should compile successfullyjavaFiles
- the Java files to be compiledprotected void runTest(java.io.File expectedFile, boolean shouldSucceed, java.io.File... javaFiles)
protected static void checkTestResult(TestRun run, java.io.File expectedFile, boolean shouldSucceed, java.lang.String javaFile, java.util.List<java.lang.String> checkerOptions)
protected static void checkTestResult(TestRun run, java.util.List<java.lang.String> expectedErrors, boolean shouldSucceed, java.lang.String javaFile, java.util.List<java.lang.String> checkerOptions)
protected static java.lang.String assertSuccess(@ReadOnly TestRun run)
run
- the test run to checkprotected static java.lang.String assertFailure(@ReadOnly TestRun run)
run
- the test run to checkprotected static void assertDiagnostics(@ReadOnly java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> actualDiagnostics, @ReadOnly java.io.File expectedDiagnosticFile, java.lang.String javaFile, java.util.List<java.lang.String> checkerOptions)
actualDiagnostics
- the list of diagnostics from the compilerexpectedDiagnosticFile
- a file containing a list of expected errors, one
per lineprotected static void assertDiagnostics(java.lang.String msg, @ReadOnly java.util.List<javax.tools.Diagnostic<? extends javax.tools.JavaFileObject>> actual_diagnostics, java.util.List<java.lang.String> expected_diagnostics, java.lang.String filename, java.util.List<java.lang.String> checkerOptions)
public static java.lang.String join(java.lang.Object[] a, java.lang.String delim)
public static java.lang.String joinPrefixed(java.lang.Object[] a, java.lang.String delim, java.lang.String prefix)