Class TestUtilities
java.lang.Object
org.checkerframework.framework.test.TestUtilities
Utilities for testing.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final booleanTrue if the JVM is version 11 or above.static final booleanTrue if the JVM is version 17 or above.static final booleanTrue if the JVM is version 18 or above.static final booleanTrue if the JVM is version 9 or above.static final booleanTrue if the JVM is version 11 or lower.static final booleanTrue if the JVM is version 17 or lower.static final booleanTrue if the JVM is version 18 or lower.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidassertTestDidNotFail(TypecheckResult testResult) If the given TypecheckResult has unexpected or missing diagnostics, fail the running JUnit test.deeplyEnclosedJavaTestFiles(File directory) Returns all the Java files that are descendants of the given directory.diagnosticsToStrings(Iterable<Diagnostic<? extends JavaFileObject>> actualDiagnostics, boolean usingAnomsgtxt) diagnosticToString(Diagnostic<? extends JavaFileObject> diagnostic, boolean usingAnomsgtxt) static voidCreate the directory (and its parents) if it does not exist.static FilefindComparisonFile(File testFile) findFilesInParent(File parent, String... fileNames) Prepends a file to the beginning of each filename.findJavaFilesPerDirectory(File parent, String... dirNames) Returns a list where each item is a list of Java files, excluding any skip tests, for each directory given by dirName and also a list for any subdirectory.findNestedJavaTestFiles(String... dirNames) findRelativeNestedJavaFiles(File parent, String... dirNames) findRelativeNestedJavaFiles(String parent, String... dirNames) getJavaFilesAsArgumentList(File... dirs) Traverses the directories listed looking for Java test files.static booleanReturns the value of system property "emit.test.debug".static FilegetTestFile(String fileRelativeToTestsDir) static booleanisJavaFile(File file) static booleanisJavaTestFile(File file) optionMapToList(Map<String, @Nullable String> options) static StringsummarizeSourceFiles(List<File> javaFiles) Return the file absolute pathnames, separated by commas.static voidwriteDiagnostics(File file, File testFile, List<String> expected, List<String> actual, List<String> unexpected, List<String> missing, boolean usingNoMsgText, boolean testFailed) static voidwriteJavacArguments(File file, Iterable<? extends JavaFileObject> files, Iterable<String> options, Iterable<String> processors) static voidwriteLines(File file, Iterable<?> lines) Write all the lines in the given Iterable to the given File.static voidwriteTestConfiguration(File file, TestConfiguration config) Append a test configuration to the end of a file.
- 
Field Details- 
IS_AT_LEAST_9_JVMpublic static final boolean IS_AT_LEAST_9_JVMTrue if the JVM is version 9 or above.
- 
IS_AT_LEAST_11_JVMpublic static final boolean IS_AT_LEAST_11_JVMTrue if the JVM is version 11 or above.
- 
IS_AT_MOST_11_JVMpublic static final boolean IS_AT_MOST_11_JVMTrue if the JVM is version 11 or lower.
- 
IS_AT_LEAST_17_JVMpublic static final boolean IS_AT_LEAST_17_JVMTrue if the JVM is version 17 or above.
- 
IS_AT_MOST_17_JVMpublic static final boolean IS_AT_MOST_17_JVMTrue if the JVM is version 17 or lower.
- 
IS_AT_LEAST_18_JVMpublic static final boolean IS_AT_LEAST_18_JVMTrue if the JVM is version 18 or above.
- 
IS_AT_MOST_18_JVMpublic static final boolean IS_AT_MOST_18_JVMTrue if the JVM is version 18 or lower.
 
- 
- 
Constructor Details- 
TestUtilitiespublic TestUtilities()
 
- 
- 
Method Details- 
findNestedJavaTestFiles
- 
findRelativeNestedJavaFiles
- 
findRelativeNestedJavaFiles
- 
findJavaFilesPerDirectoryReturns a list where each item is a list of Java files, excluding any skip tests, for each directory given by dirName and also a list for any subdirectory.- Parameters:
- parent- parent directory of the dirNames directories
- dirNames- names of directories to search
- Returns:
- list where each item is a list of Java test files grouped by directory
 
- 
findFilesInParentPrepends a file to the beginning of each filename.- Parameters:
- parent- a file to prepend to each filename
- fileNames- file names
- Returns:
- the file names, each with parentprepended
 
- 
getJavaFilesAsArgumentListTraverses the directories listed looking for Java test files.- Parameters:
- dirs- directories in which to search for Java test files
- Returns:
- a list of Java test files found in the directories
 
- 
deeplyEnclosedJavaTestFilesReturns all the Java files that are descendants of the given directory.- Parameters:
- directory- a directory
- Returns:
- all the Java files that are descendants of the given directory
 
- 
isJavaFile
- 
isJavaTestFile
- 
diagnosticToStringpublic static @Nullable String diagnosticToString(Diagnostic<? extends JavaFileObject> diagnostic, boolean usingAnomsgtxt) 
- 
diagnosticsToStringspublic static Set<String> diagnosticsToStrings(Iterable<Diagnostic<? extends JavaFileObject>> actualDiagnostics, boolean usingAnomsgtxt) 
- 
summarizeSourceFilesReturn the file absolute pathnames, separated by commas.- Parameters:
- javaFiles- a list of Java files
- Returns:
- the file absolute pathnames, separated by commas
 
- 
getTestFile
- 
findComparisonFile
- 
optionMapToList
- 
writeLinesWrite all the lines in the given Iterable to the given File.- Parameters:
- file- where to write the lines
- lines- what lines to write
 
- 
writeDiagnostics
- 
writeTestConfigurationAppend a test configuration to the end of a file.- Parameters:
- file- the file to write to
- config- the configuration to append to the end of the file
 
- 
writeJavacArguments
- 
assertTestDidNotFailIf the given TypecheckResult has unexpected or missing diagnostics, fail the running JUnit test.- Parameters:
- testResult- the result of type-checking
 
- 
ensureDirectoryExistsCreate the directory (and its parents) if it does not exist.- Parameters:
- dir- the directory to create
 
- 
getShouldEmitDebugInfopublic static boolean getShouldEmitDebugInfo()Returns the value of system property "emit.test.debug".- Returns:
- the value of system property "emit.test.debug"
 
 
-