# Runs two pytest invocations to generate separate HTML/JUnit reports
#  - Unit tests → reports/report-unit.html, reports/junit-unit.xml
#  - All non-unit tests → reports/report-tests.html, reports/junit-tests.xml
#
# Usage (from repo root, PowerShell):
#   .\scripts\run_two_reports.ps1
#
# Notes:
# - We override pytest.ini addopts to avoid duplicate --html/--junitxml and explicitly
#   load our custom plugin.
# - Adjust the second marker to exclude hardware if desired (see commented example).

# Ensure reports directory exists
if (-not (Test-Path -LiteralPath "reports")) { New-Item -ItemType Directory -Path "reports" | Out-Null }

# 1) Unit tests report
pytest -q -o addopts="" -p conftest_plugin -ra --tb=short --self-contained-html `
  --cov=ecu_framework --cov-report=term-missing `
  --html=reports/report-unit.html `
  --junitxml=reports/junit-unit.xml `
  -m unit

# 2) All non-unit tests (integration/smoke/hardware) report
# To exclude hardware here, change the marker expression to: -m "not unit and not hardware"
pytest -q -o addopts="" -p conftest_plugin -ra --tb=short --self-contained-html `
  --cov=ecu_framework --cov-report=term-missing `
  --html=reports/report-tests.html `
  --junitxml=reports/junit-tests.xml `
  -m "not unit"
