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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionNote: 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 SummaryModifier 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- 
TestConfigurationBuilderpublic TestConfigurationBuilder()Note: There are static helper methods named buildConfiguration and buildConfigurationBuilder that can be used to create the most common types of configurations
- 
TestConfigurationBuilderCreate a builder that has all of the options in initialConfig.- Parameters:
- initialConfig- initial configuration for the newly-created builder
 
 
- 
- 
Method Details- 
getDefaultConfigurationBuilderpublic 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 tests
- outputClassDirectory- the directory to place classes compiled for testing
- classPath- the classpath to use for compilation
- testSourceFiles- the Java files that compose the test
- processors- the checkers or other annotation processors to run over the testSourceFiles
- options- the options to the compiler/processors
- shouldEmitDebugInfo- whether or not debug information should be emitted
- Returns:
- the builder that will create an immutable test configuration
 
- 
buildDefaultConfigurationpublic 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 tests
- testFile- a single test Java file to compile
- processor- a single checker to include in the processors field
- options- the options to the compiler/processors
- shouldEmitDebugInfo- 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
 
- 
buildDefaultConfigurationpublic 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 tests
- testSourceFiles- the Java files that compose the test
- processors- the checkers or other annotation processors to run over the testSourceFiles
- options- the options to the compiler/processors
- shouldEmitDebugInfo- 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
 
- 
buildDefaultConfigurationpublic 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 tests
- testSourceFiles- the Java files that compose the test
- classpathExtra- extra entries for the classpath, needed to compile the source files
- processors- the checkers or other annotation processors to run over the testSourceFiles
- options- the options to the compiler/processors
- shouldEmitDebugInfo- 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
 
- 
validateEnsures 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
- 
setProcessorsSet the processors.- Parameters:
- processors- the processors to run
- Returns:
- this
 
- 
addProcessorAdd a processor.- Parameters:
- processor- a processor to run
- Returns:
- this
 
- 
addProcessorsAdd processors.- Parameters:
- processors- processors to run
- Returns:
- this
 
- 
emitDebugInfo
- 
dontEmitDebugInfo
- 
setShouldEmitDebugInfo
- 
buildCreates a TestConfiguration using the settings in this builder. The settings are NOT validated first.- Returns:
- a TestConfiguration using the settings in this builder
 
- 
validateThenBuildCreates 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
 
- 
flatOptionsReturns the set of Javac options as a flat list.- Returns:
- the set of Javac options as a flat list
 
- 
toString
- 
getOutputDirFromProperty
- 
getDefaultClassPath
 
-