#!/usr/bin/env python3
"""
Test runner for xwquery.

Company: eXonware.com
Author: eXonware Backend Team
Email: connect@exonware.com
Version: 0.0.1
Generation Date: October 11, 2025
"""

import sys
import pytest
from pathlib import Path

def main():
    """Run tests with pytest."""
    # Add project root to path
    project_root = Path(__file__).parent.parent
    sys.path.insert(0, str(project_root / "src"))
    
    # Parse command line arguments
    args = sys.argv[1:]
    
    core_dir = project_root / "tests" / "0.core"
    unit_dir = project_root / "tests" / "1.unit"
    integration_dir = project_root / "tests" / "2.integration"
    # Build pytest arguments (layered suites only)
    pytest_args = ["-v", "--tb=short"]
    
    # Add specific test types if requested
    if "--core" in args:
        pytest_args.append(str(core_dir))
        args.remove("--core")
    elif "--unit" in args:
        pytest_args.append(str(unit_dir))
        args.remove("--unit")
    elif "--integration" in args:
        pytest_args.append(str(integration_dir))
        args.remove("--integration")
    else:
        pytest_args.extend([str(core_dir), str(unit_dir), str(integration_dir)])
    
    # Add remaining arguments
    pytest_args.extend(args)
    
    # Run pytest
    exit_code = pytest.main(pytest_args)
    sys.exit(exit_code)

if __name__ == "__main__":
    main()

