"""Tests for --verify-data CLI flag (Phase 1 verification)."""
import kernbench.cli.main as cli_main


def test_cli_verify_data_flag_parsed(monkeypatch):
    """--verify-data flag is parsed and stored as True."""

    def fake_cmd_run(args) -> int:
        assert args.verify_data is True
        return 0

    monkeypatch.setattr(cli_main, "cmd_run", fake_cmd_run)
    rc = cli_main.main([
        "run", "--topology", "topology.yaml", "--bench", "qkv-gemm",
        "--verify-data",
    ])
    assert rc == 0


def test_cli_verify_data_flag_default(monkeypatch):
    """Without --verify-data, flag defaults to False."""

    def fake_cmd_run(args) -> int:
        assert args.verify_data is False
        return 0

    monkeypatch.setattr(cli_main, "cmd_run", fake_cmd_run)
    rc = cli_main.main([
        "run", "--topology", "topology.yaml", "--bench", "qkv-gemm",
    ])
    assert rc == 0


def test_cmd_run_verify_data_enables_engine():
    """--verify-data runs full pipeline with enable_data=True and DataExecutor."""
    rc = cli_main.main([
        "run", "--topology", "topology.yaml", "--bench", "qkv-gemm",
        "--device", "sip:0", "--verify-data",
    ])
    assert rc == 0


def test_cmd_run_without_verify_data_no_op_log():
    """Without --verify-data, engine runs in timing-only mode (no op_log)."""
    rc = cli_main.main([
        "run", "--topology", "topology.yaml", "--bench", "qkv-gemm",
        "--device", "sip:0",
    ])
    assert rc == 0
