"""Emit the GEMM per-stage engine wall-clock bar chart (load_ref).

Reads docs/diagrams/gemm_sweep.json (run scripts/gemm_sweep.py to refresh it)
and writes gemm_stage_breakdown.png into docs/diagrams/gemm_plots/.
"""
from __future__ import annotations

from pathlib import Path

import pytest

from tests.gemm._gemm_plot_helpers import (
    GEMM_SWEEP_JSON,
    emit_stage_breakdown,
)


@pytest.mark.skipif(
    not GEMM_SWEEP_JSON.exists(),
    reason="gemm_sweep.json absent; run scripts/gemm_sweep.py first",
)
def test_plot_gemm_stage_breakdown():
    out = emit_stage_breakdown()
    assert out is not None and Path(out).exists()
