This directory contains helper scripts for testing and development of md-book.
Purpose: Prepares the test environment and installs required tools.
Usage:
./scripts/test-setup.shWhat it does:
- Checks for required tools (cargo, pagefind, npm)
- Installs missing tools (cargo-tarpaulin, wasm-pack, cargo-deny)
- Creates test content and directories
- Runs initial code quality checks
- Displays available test commands
Prerequisites:
- Rust toolchain
- Node.js (for pagefind installation)
- Internet connection for tool installation
Purpose: Comprehensive test runner that executes all test suites.
Usage:
./scripts/run-tests.shTest Suites Included:
- Pre-flight Checks: Verify environment and project structure
- Code Quality: Formatting, Clippy, security audits
- Unit Tests: Library and binary tests
- Integration Tests: Cross-component testing
- End-to-End Tests: Full pipeline testing
- WASM Tests: WebAssembly compilation and functionality
- Frontend Tests: JavaScript/CSS functionality
- Performance Tests: Benchmark compilation
- Documentation Tests: Doc generation and doc tests
- Cross-compilation Tests: Multi-platform builds
Output: Colored status messages with final summary and success rate.
Purpose: Dedicated testing of Pagefind search functionality.
Usage:
./scripts/test-search.shTests Performed:
- Creates comprehensive test content with searchable terms
- Builds test site with search integration
- Verifies search index generation
- Checks search component integration
- Tests search asset inclusion
- Validates search query functionality
- Analyzes content indexing
Test Content: Auto-generates documentation with:
- Installation guides
- Configuration documentation
- API references
- Tutorials and guides
- Various search terms and keywords
Prerequisites: pagefind CLI tool must be installed
Purpose: Performance benchmarking and analysis.
Usage:
./scripts/benchmark.shBenchmarks Include:
- Build Performance: Tests with small (10), medium (50), and large (200) page datasets
- Memory Usage: Peak memory consumption during builds
- Search Indexing: Time to generate search indexes
- Criterion Integration: Automated benchmark suite integration
Outputs:
benchmark_data/build_results.txt: CSV data of build performancebenchmark_data/report.md: Comprehensive performance reportbenchmark_data/memory_usage.txt: Memory analysis (if available)benchmark_data/criterion_results.json: Criterion benchmark results
Generated Data: Creates test datasets of various sizes for consistent benchmarking.
-
First-time setup:
./scripts/test-setup.sh
-
Run all tests:
./scripts/run-tests.sh
-
Test search specifically:
./scripts/test-search.sh
-
Performance analysis:
./scripts/benchmark.sh
These scripts are designed to work both locally and in CI environments:
- GitHub Actions: Scripts handle missing tools gracefully
- Local Development: Full tool installation and setup
- Cross-platform: Works on Linux, macOS, and Windows (with appropriate shell)
Script not executable:
chmod +x scripts/*.shTool not found errors:
- Run
test-setup.shfirst to install required tools - Check that Node.js is installed for pagefind
- Verify Rust toolchain is properly installed
Test failures:
- Check that you're in the project root directory
- Ensure all dependencies are installed via
test-setup.sh - Review test output for specific error messages
| Tool | Purpose | Installation |
|---|---|---|
cargo |
Rust package manager | Rust toolchain |
pagefind |
Search indexing | npm install -g pagefind |
cargo-tarpaulin |
Coverage analysis | cargo install cargo-tarpaulin |
wasm-pack |
WASM testing | curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh |
cargo-deny |
Security auditing | cargo install cargo-deny |
node/npm |
Frontend testing | Node.js installation |
Recommended workflow for contributors:
- Initial setup:
./scripts/test-setup.sh - Development cycle:
- Make changes to code
- Run
./scripts/run-tests.shto verify - Test search specifically with
./scripts/test-search.sh
- Performance testing:
./scripts/benchmark.shfor performance-critical changes - Pre-commit: Ensure all tests pass before committing
When modifying these scripts:
- Maintain backward compatibility
- Add appropriate error handling
- Update this README with changes
- Test scripts on different platforms
- Keep tool version requirements up to date