Circuit-Synth Testing Guide๏ƒ

This document describes the comprehensive testing infrastructure for the circuit-synth project.

Testing Architecture Overview๏ƒ

๐Ÿ Python Tests (Primary)๏ƒ

  • 165 tests passing, 7 skipped โœ…

  • Tests all Python functionality and user-facing features

  • Provides comprehensive end-to-end validation

  • Run with: uv run pytest

  • Independent of Python integration for performance validation

  • Run individually per module

๐Ÿ”— Integration Tests๏ƒ

  • Fallback behavior testing

โš™๏ธ Core Tests๏ƒ

  • End-to-end functionality validation

  • Run with: uv run python examples/example_kicad_project.py

Quick Start๏ƒ

Traditional Testing Commands๏ƒ

# Python tests
uv run pytest


# Integration tests

Testing Scripts๏ƒ

scripts/run_all_tests.sh๏ƒ

Unified test runner that orchestrates all testing:

  • โœ… Python unit tests (pytest)

  • โœ… Core functionality test (examples/example_kicad_project.py)

  • โœ… Comprehensive summary report

Options:

  • --python-only: Run only Python tests

  • --verbose: Show detailed output

  • --fail-fast: Stop on first failure

  • ๐Ÿ“Š Reports detailed results in JSON format

  • โšก Parallel testing with proper error handling

Features:

  • Python integration testing for all modules

  • Comprehensive error reporting

  • CI/CD integration ready

# Results: 30/32 tests passing (excellent coverage)

Method 2: Test with Python Integration๏ƒ

# Build Python bindings and test
  • Python integration: All bindings working

  • Import tests: All successful

โš ๏ธ Expected Issues:

  • Import errors: Check Python path and module installation

  • Some unit test failures: Minor string processing issues, not critical

  • Missing modules: Some modules are still in development

GitHub Actions CI/CD๏ƒ

Automatic PR Testing๏ƒ

When you create a PR, GitHub Actions automatically:

  1. ๐Ÿ” Runs Clippy lints for code quality

  2. ๐Ÿ’ฌ Comments on PR with detailed test results

  3. ๐Ÿ“ Uploads test artifacts for debugging

Workflow Triggers๏ƒ

  • โœ… Pull requests to main or develop

  • โœ… Pushes to main or develop

  • โœ… Manual workflow dispatch

Test Matrix๏ƒ

The CI runs on:

  • Python 3.12 with uv package manager

  • System dependencies (jq, build tools)

Pre-commit Hooks๏ƒ

Optional pre-commit hooks prevent issues before commit:

# Install pre-commit hooks
./tools/build/setup_formatting.sh

# Run manually
pre-commit run --all-files

Hooks include:

  • โœ… Linting (flake8, clippy)

  • โœ… Import sorting (isort)

  • โœ… Basic file checks

Test Results & Reporting๏ƒ

JSON Output Format๏ƒ

{
  "timestamp": "2025-01-27T10:30:00Z",
  "modules": {
      "status": "passed",
      "tests_passed": 30,
      "tests_failed": 2,
      "error_message": ""
    }
  },
  "summary": {
    "total_modules": 9,
    "tested_modules": 5,
    "passing_modules": 4,
    "failing_modules": 1,
    "skipped_modules": 4
  }
}

PR Comments๏ƒ

GitHub Actions automatically comment on PRs with:

  • ๐Ÿ“Š Summary table of test results

  • โŒ Failed module details if any

  • ๐Ÿ“ Detailed JSON results in collapsible section

  • โœ… Success confirmation when all tests pass

Troubleshooting๏ƒ

Common Issues๏ƒ

dyld: symbol not found '_PyBool_Type'

Solution: Use --no-default-features flag to avoid Python dependencies

Missing dependencies:


Python import failures:


Debug Commands๏ƒ

# Check toolchain versions
uv --version
python --version

# Verbose test output

# Test specific module

# Clear caches and test fresh
./tools/maintenance/clear_all_caches.sh
./tools/testing/run_full_regression_tests.py

Integration with CLAUDE.md๏ƒ

The automated testing is integrated with CLAUDE.md workflows:

  • Core circuit test: uv run python examples/example_kicad_project.py

  • Unit tests: uv run pytest tests/unit/test_core_circuit.py -v

  • Comprehensive: ./tools/testing/run_full_regression_tests.py

This ensures both manual and automated testing follow the same validation patterns.

Why This Architecture Works๏ƒ

  1. Python tests validate user functionality - This is what users actually use

Benefits๏ƒ

โœ… Faster feedback - Catch issues immediately on PR creation
โœ… Consistent testing - Same tests run locally and in CI
โœ… Clear reporting - Detailed results with actionable information
โœ… Easy maintenance - Auto-discovery and JSON output for tooling
โœ… Developer friendly - Simple commands and helpful error messages