Shared Go module for CCL test loading infrastructure, providing modern dual-format test suite support with type-safe filtering.
This library addresses code duplication between CCL Go projects by providing:
- Unified test structures supporting both source and flat formats
- Type-safe filtering based on implementation capabilities
- Modern test loading with capability-driven compatibility
- Flat format generation for implementation-friendly test consumption
github.com/tylerbu/ccl-test-lib/
├── types/ # Unified test data structures
├── config/ # Implementation capability declaration
├── loader/ # Test loading and filtering
└── generator/ # Flat format generation utilities
import "github.com/tylerbu/ccl-test-lib/config"
impl := config.ImplementationConfig{
Name: "my-ccl-impl",
Version: "v1.0.0",
SupportedFunctions: []config.CCLFunction{
config.FunctionParse,
config.FunctionBuildHierarchy,
config.FunctionGetString,
config.FunctionGetInt,
},
SupportedFeatures: []config.CCLFeature{
config.FeatureComments,
config.FeatureMultiline,
},
BehaviorChoices: []config.CCLBehavior{
config.BehaviorCRLFNormalize,
config.BehaviorBooleanLenient,
},
VariantChoice: config.VariantProposed,
}import ccl "github.com/tylerbu/ccl-test-lib"
// Simple approach
tests, err := ccl.LoadCompatibleTests("../ccl-test-data", impl)
if err != nil {
log.Fatal(err)
}
// Advanced approach with options
loader := ccl.NewLoader("../ccl-test-data", impl)
tests, err := loader.LoadAllTests(loader.LoadOptions{
Format: loader.FormatFlat,
FilterMode: loader.FilterCompatible,
LevelLimit: 4, // Skip Level 5 tests
})for _, test := range tests {
switch test.Validation {
case "parse":
runParseTest(test)
case "build_hierarchy":
runBuildHierarchyTest(test)
case "get_string":
runGetStringTest(test)
}
}// Simple generation
err := ccl.GenerateFlat("source_tests", "generated_tests")
if err != nil {
log.Fatal(err)
}
// Advanced generation with options
gen := generator.NewFlatGenerator("source_tests", "generated_tests", generator.GenerateOptions{
SkipPropertyTests: false,
OnlyFunctions: []config.CCLFunction{
config.FunctionParse,
config.FunctionBuildHierarchy,
},
Verbose: true,
})
err := gen.GenerateAll()- Modernized to dual-format architecture (source + flat)
- Simplified test runners - switch on
test.Validationinstead of complex tag parsing - Better performance - direct field access vs string parsing
- Type-safe filtering - declare capabilities, get compatible tests automatically
- Shared infrastructure - test loading logic becomes reusable
- Reduced duplication - single source of truth for test structures
- Better maintainability - changes to test format only need updates in one place
- Language-agnostic patterns - architecture translates to other languages
- Progressive adoption - clear path from minimal to full CCL support
- Standardized filtering - consistent capability declaration across implementations
Human-maintainable with multiple validations per test case. Example:
{
"name": "basic_parsing",
"input": "key = value",
"validations": {
"parse": [{"key": "value"}],
"get_string": {"args": ["key"], "expected": "value"}
}
}Implementation-friendly with single validation per test case. Example:
{
"name": "basic_parsing_parse",
"input": "key = value",
"validation": "parse",
"expected": [{"key": "value"}]
}Instead of string-based tag parsing, use structured metadata:
test.Functions []string // ["parse", "get_string"]
test.Features []string // ["comments", "multiline"]
test.Behaviors []string // ["crlf_normalize_to_lf"]
test.Variants []string // ["proposed_behavior"]
test.Conflicts *ConflictSet // Mutually exclusive requirementstypes.TestSuite- Test suite containertypes.TestCase- Individual test case (source or flat)types.TestStatistics- Comprehensive test analysis
config.ImplementationConfig- Capability declarationconfig.CCLFunction- Type-safe function identifiersconfig.CCLFeature- Type-safe feature identifiersconfig.CCLBehavior- Type-safe behavior choices
loader.TestLoader- Main test loading interfaceloader.LoadOptions- Loading behavior controlLoadCompatibleTests()- Convenience function
generator.FlatGenerator- Source to flat transformationgenerator.GenerateOptions- Generation behavior controlGenerateFlat()- Convenience function
Use external tools for JSON schema validation:
# Validate with jv or similar tools
jv schema.json < test-file.jsonThe library focuses on semantic validation and compatibility checking rather than schema validation.