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 Details

    • AinferValidatePerDirectoryTest

      protected AinferValidatePerDirectoryTest(List<File> testFiles, Class<? extends AbstractProcessor> checker, String checkerShortName, String testDir, Class<? extends AinferGeneratePerDirectoryTest> generationTest, 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 Details

    • ajavaArgFromFiles

      protected static String ajavaArgFromFiles(List<File> sourceFiles, 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 String astubsArgFromFiles(List<File> sourceFiles, 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
    • run

      public void run()
      Description copied from class: CheckerFrameworkPerDirectoryTest
      Run the tests.
      Overrides:
      run in class CheckerFrameworkPerDirectoryTest
    • resolveTestDirectory

      protected 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