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) Adds the given diagnostics file tothis.addDiagnosticFiles(Iterable<File> diagnostics) Adds the given diagnostics files tothis.adddToPathOption(String key, String toAppend) Adds the given path option tothis.Adds the given option tothis.Adds the given option and value tothis.addOptionIfValueNonEmpty(String option, String value) Adds the given option tothisif the value is non-empty.addOptions(Iterable<String> newOptions) Adds the given options tothis.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) Adds the given source file tothis.addSourceFiles(Iterable<File> sourceFiles) Adds the given source files tothis.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.Setsthisto not output debug info.Setsthisto output debug info.Returns the set of Javac options as a flat list.static StringDetermine the default classpath from thetests.classpathproperty.static 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 FileDetermine the output directory from thetests.outputDirproperty.setDiagnosticFiles(List<File> diagnosticFiles) Sets the diagnostics files ofthis.setOptions(Map<String, @Nullable String> options) Sets the given options onthis.setProcessors(Iterable<@BinaryName String> processors) Set the processors.setShouldEmitDebugInfo(boolean shouldEmitDebugInfo) Setsthisto output debug info depending on the parameter.setSourceFiles(List<File> sourceFiles) Sets the source files ofthis.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_OUTPUTDIRThe output directory for tests.- 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
 
- 
adddToPathOptionAdds the given path option tothis.- Parameters:
- key- the key to add
- toAppend- the path to append
- Returns:
- the current object this
 
- 
addDiagnosticFileAdds the given diagnostics file tothis.- Parameters:
- diagnostics- the diagnostics file to add to- this
- Returns:
- the current object this
 
- 
addDiagnosticFilesAdds the given diagnostics files tothis.- Parameters:
- diagnostics- diagnostics files to add to- this
- Returns:
- the current object this
 
- 
setDiagnosticFilesSets the diagnostics files ofthis.- Parameters:
- diagnosticFiles- diagnostics files to set on- this
- Returns:
- the current object this
 
- 
addSourceFileAdds the given source file tothis.- Parameters:
- sourceFile- source file to add to- this
- Returns:
- the current object this
 
- 
addSourceFilesAdds the given source files tothis.- Parameters:
- sourceFiles- source files to add to- this
- Returns:
- the current object this
 
- 
setSourceFilesSets the source files ofthis.- Parameters:
- sourceFiles- source files to set on- this
- Returns:
- the current object this
 
- 
setOptionsSets the given options onthis.- Parameters:
- options- options to set on- this
- Returns:
- the current object this
 
- 
addOptionAdds the given option tothis.- Parameters:
- option- option to add to- this
- Returns:
- the current object this
 
- 
addOptionAdds the given option and value tothis.- Parameters:
- option- option to add to- this
- value- value to add
- Returns:
- the current object this
 
- 
addOptionIfValueNonEmptyAdds the given option tothisif the value is non-empty.- Parameters:
- option- option to add to- this
- value- value to add, iff it is non-empty
- Returns:
- the current object this
 
- 
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
 
- 
addOptionsAdds the given options tothis.- Parameters:
- newOptions- options to add to- this
- Returns:
- the current object this
 
- 
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
 
- 
emitDebugInfoSetsthisto output debug info.- Returns:
- the current object this
 
- 
dontEmitDebugInfoSetsthisto not output debug info.- Returns:
- the current object this
 
- 
setShouldEmitDebugInfoSetsthisto output debug info depending on the parameter.- Parameters:
- shouldEmitDebugInfo- whether to emit debug info
- Returns:
- the current object this
 
- 
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
- 
getOutputDirFromPropertyDetermine the output directory from thetests.outputDirproperty.- Returns:
- the output directory
 
- 
getDefaultClassPathDetermine the default classpath from thetests.classpathproperty.- Returns:
- the default classpath
 
 
-