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