#!/usr/bin/env python3
#exonware/xwsyntax/tests/1.unit/bidirectional_tests/runner.py
"""
Test runner for bidirectional module.
Company: eXonware.com
Author: eXonware Backend Team
Email: connect@exonware.com
Version: 0.0.1
"""

import sys
import pytest
from pathlib import Path
from datetime import datetime
# ⚠️ CRITICAL: Configure UTF-8 encoding for Windows console using xwsystem utility
from exonware.xwsystem.console.cli import ensure_utf8_console
ensure_utf8_console()


def main():
    """Run tests for bidirectional module."""
    src_path = Path(__file__).parent.parent.parent.parent / "src"
    sys.path.insert(0, str(src_path))
    module_name = "bidirectional"
    print(f"   Testing: {module_name}")
    exit_code = pytest.main([
        "-v",
        "--tb=short",
        str(Path(__file__).parent),
        "-m", "xwsyntax_unit"
    ])
    status = "PASSED" if exit_code == 0 else "FAILED"
    output_file = Path(__file__).parent / "runner_out.md"
    markdown_content = f"""# Module Test Results: {module_name}
**Module:** {module_name}  
**Layer:** 1.unit  
**Generated:** {datetime.now().strftime("%d-%b-%Y %H:%M:%S")}  
**Status:** {status}
---
**Exit Code:** {exit_code}
---
*Generated by eXonware test runner*
"""
    output_file.write_text(markdown_content, encoding='utf-8')
    sys.exit(exit_code)
if __name__ == "__main__":
    main()
