Start real LangBot process for E2E testing. This fixture starts LangBot once per session and reuses it for all tests. Coverage data is collected from the subprocess.
(e2e_config_path, e2e_port, e2e_tmpdir)
| 49 | |
| 50 | @pytest.fixture(scope='session') |
| 51 | def langbot_process(e2e_config_path, e2e_port, e2e_tmpdir): |
| 52 | """Start real LangBot process for E2E testing. |
| 53 | |
| 54 | This fixture starts LangBot once per session and reuses it for all tests. |
| 55 | Coverage data is collected from the subprocess. |
| 56 | """ |
| 57 | project_root = find_project_root() |
| 58 | collect_coverage = True |
| 59 | |
| 60 | proc = LangBotProcess( |
| 61 | project_root=project_root, |
| 62 | work_dir=e2e_tmpdir, # Run in tmpdir where data/config.yaml exists |
| 63 | port=e2e_port, |
| 64 | timeout=60, # Longer timeout for first startup |
| 65 | collect_coverage=collect_coverage, |
| 66 | ) |
| 67 | |
| 68 | success = proc.start() |
| 69 | if not success: |
| 70 | stdout, stderr = proc.get_logs() |
| 71 | pytest.fail(f'LangBot failed to start:\nstdout: {stdout}\nstderr: {stderr}') |
| 72 | |
| 73 | yield proc |
| 74 | |
| 75 | # Cleanup |
| 76 | proc.stop() |
| 77 | |
| 78 | # Combine coverage data if collected |
| 79 | if collect_coverage and proc.get_coverage_file(): |
| 80 | coverage_file = proc.get_coverage_file() |
| 81 | if coverage_file.exists(): |
| 82 | # Copy coverage data to project root for combining |
| 83 | target = project_root / '.coverage.e2e' |
| 84 | shutil.copy(coverage_file, target) |
| 85 | logger.info(f'Coverage data saved to: {target}') |
| 86 | |
| 87 | |
| 88 | @pytest.fixture |
nothing calls this directly
no test coverage detected