Quick Start
Running All Tests
From the repository root:MAX_CHAPTER limit (currently chapter 6).
Running Ignored Tests
Tests beyond the chapter cap are marked as ignored:Test Filtering
libtest-mimic provides standard Rust test filtering:By Chapter
By Test Kind
By Specific Test
Combined Filters
Test Output
Success Output
Failure Output
When a test fails, the framework provides detailed diagnostics:libtest-mimic Options
The test binary supports standard libtest-mimic arguments:List Tests
Exact Matching
Show Output
Test Threads
Using cargo nextest
The integration tests also work with cargo nextest, which provides faster test execution:- Faster test execution through better parallelism
- Cleaner test output with progress indicators
- Better failure reporting
- Test retries and flake detection
CI Integration
In continuous integration, run the full test suite:Environment Variables
The test framework respects standard environment variables:CC Variable
CC variable determines which compiler is used to:
- Run the preprocessor (
cc -E -P) - Assemble and link the final binary
RUST_LOG Variable
Troubleshooting
No Tests Discovered
If no tests are discovered:-
Verify the
writing-a-c-compiler-testssubmodule is initialized: -
Check that test directories exist:
Tests Failing Unexpectedly
- Check compiler features: Ensure your compiler supports the features being tested
-
Verify expected results: Check
expected_results.jsonfor the correct expectations -
Run with logging: Enable debug output to see compilation details:
-
Run serially: Disable parallel execution to isolate issues:
Compilation Stage Mismatches
If tests are failing at unexpected stages, check for structural differences:- MCC may report errors at different stages than expected by the book
- See the
ignoredarray inintegration.rsfor examples - Consider whether the difference is intentional or a bug
Performance Issues
If tests are slow:-
Use nextest:
cargo nextestis significantly faster thancargo test -
Limit chapters: Adjust
MAX_CHAPTERinintegration.rsduring development -
Filter tests: Run only the tests you’re working on:
-
Use release builds: For faster test execution (slower compilation):