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