Class AinferValidatePerDirectoryTest


  • public class AinferValidatePerDirectoryTest
    extends CheckerFrameworkWPIPerDirectoryTest
    A specialized variant of CheckerFrameworkPerDirectoryTest for testing the Whole Program Inference feature of the Checker Framework, which is tested by running pairs of these tests: a "generation test" (of class AinferGeneratePerDirectoryTest) to do inference using the -Ainfer option, and a "validation test" (of this class) to check that files typecheck after those inferences are taken into account.
    • Constructor Detail

      • AinferValidatePerDirectoryTest

        protected AinferValidatePerDirectoryTest​(java.util.List<java.io.File> testFiles,
                                                 java.lang.Class<? extends javax.annotation.processing.AbstractProcessor> checker,
                                                 java.lang.String checkerShortName,
                                                 java.lang.String testDir,
                                                 java.lang.Class<? extends AinferGeneratePerDirectoryTest> generationTest,
                                                 java.lang.String... checkerOptions)
        Creates a new checker test. Use this constructor when creating a validation test.

        TestConfigurationBuilder.getDefaultConfigurationBuilder(String, File, String, Iterable, Iterable, List, boolean) adds additional checker options.

        Parameters:
        testFiles - the files containing test code, which will be type-checked
        checker - the class for the checker to use
        checkerShortName - the short name of the checker, as used in the naming conventions for files, e.g. "index" for the Index Checker or "testchecker" for the AInferTestChecker
        testDir - the path to the directory of test inputs
        generationTest - the class of the test that must run before this test, if this is the second of a pair of tests
        checkerOptions - options to pass to the compiler when running tests
    • Method Detail

      • ajavaArgFromFiles

        protected static java.lang.String ajavaArgFromFiles​(java.util.List<java.io.File> sourceFiles,
                                                            java.lang.String checkerShortName)
        Computes the -Aajava argument that corresponds to the test files. This method is necessary because the framework issues a warning if a .ajava file with no corresponding source file is specified.

        Assumes that ajava files will be in the #getInferenceBaseDir(String) directory.

        Parameters:
        sourceFiles - the list of source files
        checkerShortName - the short name of the checker, as used in the naming conventions for files, e.g. "index" for the Index Checker or "testchecker" for the AInferTestChecker
        Returns:
        the appropriate -Aajava argument
      • astubsArgFromFiles

        protected static java.lang.String astubsArgFromFiles​(java.util.List<java.io.File> sourceFiles,
                                                             java.lang.String checkerShortName)
        Computes the -Astubs argument that corresponds to the test files. This method is necessary because the framework issues a warning if a .astub file with no corresponding source file is specified.

        Assumes that astub files will be in the #getInferenceBaseDir(String) directory.

        Parameters:
        sourceFiles - the list of source files
        checkerShortName - the short name of the checker, as used in the naming conventions for files, e.g. "index" for the Index Checker or "testchecker" for the AInferTestChecker
        Returns:
        the appropriate -Astubs argument
      • resolveTestDirectory

        protected java.io.File resolveTestDirectory()
        Resolves the test root directory from the optional TestRootDirectory annotation or falls back to the default of currentDir/tests.
        Returns:
        the resolved directory
      • checkResult

        public void checkResult​(TypecheckResult typecheckResult)
        Check that the TypecheckResult did not fail.
        Parameters:
        typecheckResult - result to check