This document describes the test suite for the ado-aw compiler.
The test suite consists of:
- Unit tests - Located in
src/main.rs(in thetestsmodule) - Integration tests - Located in
tests/compiler_tests.rs
To run all tests:
cargo testTo run only unit tests:
cargo test --libTo run only integration tests:
cargo test --test compiler_testsTo run a specific test:
cargo test test_sanitize_filenameTo run tests with output:
cargo test -- --nocaptureUnit tests are located in the tests module at the bottom of src/main.rs. These tests cover individual functions:
Tests the filename sanitization function with various inputs including:
- Spaces and special characters
- Numbers and mixed case
- Leading/trailing dashes
- Edge cases
Tests schedule generation for:
- Hourly schedules
- Daily schedules
- Deterministic behavior (same input produces same output)
Tests repository YAML generation for:
- Empty repository list
- Single repository
- Multiple repositories
Tests checkout step generation for:
- Empty repository list
- Multiple repositories
Tests copilot parameter generation for:
- Built-in MCPs (enabled)
- Built-in MCPs (disabled)
- Custom MCPs (should be skipped)
Tests markdown parsing for:
- Valid markdown with front matter
- Missing front matter
- Unclosed front matter
- Invalid YAML in front matter
Tests the default repository reference value.
Integration tests are located in tests/compiler_tests.rs. These tests verify the overall behavior of the compiler:
Tests the basic compilation workflow including:
- Creating temporary test directories
- Writing test input files
- Verifying directory structure
Verifies that the base template contains all required markers:
{{ repositories }}{{ schedule }}{{ checkout_repositories }}{{ agent }}{{ agent_name }}{{ engine_run }}
Validates the example file (examples/sample-agent.md) to ensure:
- Proper YAML front matter structure
- Required fields are present
- Closing front matter delimiter exists
Documents expected behavior for various filename sanitization scenarios.
Verifies that all required dependencies are present in Cargo.toml:
- clap
- anyhow
- serde
- serde_yaml
The current test suite provides coverage for:
- ✅ Filename sanitization
- ✅ Schedule generation
- ✅ Repository configuration generation
- ✅ Checkout step generation
- ✅ Copilot parameter generation
- ✅ Markdown parsing
- ✅ Template structure validation
- ✅ Example file validation
- ✅ Dependency verification
When adding new functionality to the compiler:
-
Add unit tests for new helper functions in
src/main.rs:#[test] fn test_new_function() { // Test code here }
-
Add integration tests for end-to-end functionality in
tests/compiler_tests.rs:#[test] fn test_new_integration_scenario() { // Test code here }
-
Follow naming conventions:
- Unit test names:
test_<function_name>_<scenario> - Integration test names:
test_<feature>_<scenario>
- Unit test names:
-
Include edge cases:
- Empty inputs
- Invalid inputs
- Boundary conditions
- Error cases
All tests should:
- Be self-contained and not depend on external state
- Clean up any resources they create
- Use descriptive assertion messages
- Follow the Arrange-Act-Assert pattern
- Test both success and failure cases
These tests are designed to run in CI/CD pipelines. Ensure all tests pass before submitting pull requests:
cargo test --all
cargo clippy -- -D warnings
cargo fmt -- --check