Class TestConfigurationValidator
java.lang.Object
org.ek9lang.cli.TestConfigurationValidator
Validates test configuration and reports errors with proper error codes.
This validator checks for configuration problems in test directories: missing expected files, orphan files, argument count mismatches, typos, etc. It integrates with VerboseErrorMessages for detailed error explanations.
Error levels match the compiler's -E0/-E1/-E2/-E3 pattern:
- E0 - Minimal: Just error code and short message
- E1 - Visual: Formatted with location context
- E2 - Fuzzy: Includes "Did you mean?" suggestions
- E3 - Verbose: Full explanation from VerboseErrorMessages
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA test configuration issue with error code, location, message, and optional suggestion. -
Constructor Summary
ConstructorsConstructorDescriptionCreate validator with default error level (minimal).TestConfigurationValidator(int errorLevel) Create validator with specified error verbosity level. -
Method Summary
Modifier and TypeMethodDescriptionFormat an error for display based on error level.validateArgumentCount(TestProgram testProgram, int argumentCount, String caseId, Path argFile) Validate argument count for a specific test case.validateDirectory(Path sourceDir) Validate test configuration in a directory.validateParameterizedTestHasArgs(TestProgram testProgram, Path sourceDir) Validate that a program with parameters has commandline files.
-
Constructor Details
-
TestConfigurationValidator
public TestConfigurationValidator(int errorLevel) Create validator with specified error verbosity level.- Parameters:
errorLevel- 0=minimal, 1=visual, 2=fuzzy, 3=verbose
-
TestConfigurationValidator
public TestConfigurationValidator()Create validator with default error level (minimal).
-
-
Method Details
-
validateDirectory
Validate test configuration in a directory.Checks for:
- E81001: Missing expected output files
- E81002: Orphan expected output files
- E81008: Duplicate case IDs
- E81009: File name typos (via fuzzy matching)
- Parameters:
sourceDir- The directory containing test files- Returns:
- List of validation errors (empty if valid)
-
validateArgumentCount
public TestConfigurationValidator.TestConfigurationIssue validateArgumentCount(TestProgram testProgram, int argumentCount, String caseId, Path argFile) Validate argument count for a specific test case.- Parameters:
testProgram- The test program with declared parametersargumentCount- Number of arguments in commandline filecaseId- The test case ID (for error messages)argFile- Path to the commandline file- Returns:
- Optional validation issue, or null if valid
-
validateParameterizedTestHasArgs
public TestConfigurationValidator.TestConfigurationIssue validateParameterizedTestHasArgs(TestProgram testProgram, Path sourceDir) Validate that a program with parameters has commandline files.- Parameters:
testProgram- The test program to checksourceDir- The source directory- Returns:
- Optional validation issue, or null if valid
-
formatError
Format an error for display based on error level.- Parameters:
issue- The validation issue to format- Returns:
- Formatted error string
-