Class TestConfigurationBuilder
java.lang.Object
org.checkerframework.framework.test.TestConfigurationBuilder
Used to create an instance of TestConfiguration. TestConfigurationBuilder is fluent: it returns
itself after every call so you can string together configuration methods as follows:
new TestConfigurationBuilder() .addOption("-Awarns") .addSourceFile("src1.java")
.addDiagnosticFile("src1.out")
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNote: There are static helper methods named buildConfiguration and buildConfigurationBuilder that can be used to create the most common types of configurationsTestConfigurationBuilder(TestConfiguration initialConfig) Create a builder that has all of the options in initialConfig. -
Method Summary
Modifier and TypeMethodDescriptionaddDiagnosticFile(File diagnostics) addDiagnosticFiles(Iterable<File> diagnostics) adddToPathOption(String key, String toAppend) addOptionIfValueNonEmpty(String option, String value) addOptions(Iterable<String> newOptions) addOptions(Map<String, @Nullable String> options) Adds the given options to this.addProcessor(@BinaryName String processor) Add a processor.addProcessors(Iterable<@BinaryName String> processors) Add processors.addSourceFile(File sourceFile) addSourceFiles(Iterable<File> sourceFiles) build()Creates a TestConfiguration using the settings in this builder.static TestConfigurationbuildDefaultConfiguration(String testSourcePath, File testFile, Class<?> processor, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.static TestConfigurationbuildDefaultConfiguration(String testSourcePath, Iterable<File> testSourceFiles, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.static TestConfigurationbuildDefaultConfiguration(String testSourcePath, Iterable<File> testSourceFiles, Collection<String> classpathExtra, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.Returns the set of Javac options as a flat list.static Stringstatic TestConfigurationBuildergetDefaultConfigurationBuilder(String testSourcePath, File outputClassDirectory, String classPath, Iterable<File> testSourceFiles, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This creates a builder for the default configuration used by Checker Framework JUnit tests.static FilesetDiagnosticFiles(List<File> diagnosticFiles) setOptions(Map<String, @Nullable String> options) setProcessors(Iterable<@BinaryName String> processors) Set the processors.setShouldEmitDebugInfo(boolean shouldEmitDebugInfo) setSourceFiles(List<File> sourceFiles) toString()validate(boolean requireProcessors) Ensures that the minimum requirements for running a test are met.validateThenBuild(boolean requireProcessors) Creates a TestConfiguration using the settings in this builder.
-
Field Details
-
TESTS_OUTPUTDIR
- See Also:
-
-
Constructor Details
-
TestConfigurationBuilder
public TestConfigurationBuilder()Note: There are static helper methods named buildConfiguration and buildConfigurationBuilder that can be used to create the most common types of configurations -
TestConfigurationBuilder
Create a builder that has all of the options in initialConfig.- Parameters:
initialConfig- initial configuration for the newly-created builder
-
-
Method Details
-
getDefaultConfigurationBuilder
public static TestConfigurationBuilder getDefaultConfigurationBuilder(String testSourcePath, File outputClassDirectory, String classPath, Iterable<File> testSourceFiles, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This creates a builder for the default configuration used by Checker Framework JUnit tests.- Parameters:
testSourcePath- the path to the Checker test file sources, usually this is the directory of Checker's testsoutputClassDirectory- the directory to place classes compiled for testingclassPath- the classpath to use for compilationtestSourceFiles- the Java files that compose the testprocessors- the checkers or other annotation processors to run over the testSourceFilesoptions- the options to the compiler/processorsshouldEmitDebugInfo- whether or not debug information should be emitted- Returns:
- the builder that will create an immutable test configuration
-
buildDefaultConfiguration
public static TestConfiguration buildDefaultConfiguration(String testSourcePath, File testFile, Class<?> processor, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.- Parameters:
testSourcePath- the path to the Checker test file sources, usually this is the directory of Checker's teststestFile- a single test Java file to compileprocessor- a single checker to include in the processors fieldoptions- the options to the compiler/processorsshouldEmitDebugInfo- whether or not debug information should be emitted- Returns:
- a TestConfiguration with input parameters added plus the normal default options, compiler, and file manager used by Checker Framework tests
-
buildDefaultConfiguration
public static TestConfiguration buildDefaultConfiguration(String testSourcePath, Iterable<File> testSourceFiles, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.- Parameters:
testSourcePath- the path to the Checker test file sources, usually this is the directory of Checker's teststestSourceFiles- the Java files that compose the testprocessors- the checkers or other annotation processors to run over the testSourceFilesoptions- the options to the compiler/processorsshouldEmitDebugInfo- whether or not debug information should be emitted- Returns:
- a TestConfiguration with input parameters added plus the normal default options, compiler, and file manager used by Checker Framework tests
-
buildDefaultConfiguration
public static TestConfiguration buildDefaultConfiguration(String testSourcePath, Iterable<File> testSourceFiles, Collection<String> classpathExtra, Iterable<@BinaryName String> processors, List<String> options, boolean shouldEmitDebugInfo) This is the default configuration used by Checker Framework JUnit tests.- Parameters:
testSourcePath- the path to the Checker test file sources, usually this is the directory of Checker's teststestSourceFiles- the Java files that compose the testclasspathExtra- extra entries for the classpath, needed to compile the source filesprocessors- the checkers or other annotation processors to run over the testSourceFilesoptions- the options to the compiler/processorsshouldEmitDebugInfo- whether or not debug information should be emitted- Returns:
- a TestConfiguration with input parameters added plus the normal default options, compiler, and file manager used by Checker Framework tests
-
validate
Ensures that the minimum requirements for running a test are met. These requirements are:- There is at least one source file
- There is at least one processor (if requireProcessors has been set to true)
- There is an output directory specified for class files
- There is no
-processoroption in the optionMap (it should be added by addProcessor instead)
- Parameters:
requireProcessors- whether or not to require that there is at least one processor- Returns:
- a list of errors found while validating this configuration
-
adddToPathOption
-
addDiagnosticFile
-
addDiagnosticFiles
-
setDiagnosticFiles
-
addSourceFile
-
addSourceFiles
-
setSourceFiles
-
setOptions
-
addOption
-
addOption
-
addOptionIfValueNonEmpty
-
addOptions
@RequiresNonNull("this.options") public TestConfigurationBuilder addOptions(@UnknownInitialization(TestConfigurationBuilder.class) TestConfigurationBuilder this, Map<String, @Nullable String> options) Adds the given options to this.- Parameters:
options- options to add to this- Returns:
- this
-
addOptions
-
setProcessors
Set the processors.- Parameters:
processors- the processors to run- Returns:
- this
-
addProcessor
Add a processor.- Parameters:
processor- a processor to run- Returns:
- this
-
addProcessors
Add processors.- Parameters:
processors- processors to run- Returns:
- this
-
emitDebugInfo
-
dontEmitDebugInfo
-
setShouldEmitDebugInfo
-
build
Creates a TestConfiguration using the settings in this builder. The settings are NOT validated first.- Returns:
- a TestConfiguration using the settings in this builder
-
validateThenBuild
Creates a TestConfiguration using the settings in this builder. The settings are first validated and a runtime exception is thrown if any errors are found- Parameters:
requireProcessors- whether or not there should be at least 1 processor specified, see method validate- Returns:
- a TestConfiguration using the settings in this builder
-
flatOptions
Returns the set of Javac options as a flat list.- Returns:
- the set of Javac options as a flat list
-
toString
-
getOutputDirFromProperty
-
getDefaultClassPath
-