"""Stage/backstage detection — Mercury kernels carry MERCURY_CONFIG_DIR."""

from diaglib import staging


def test_backstage_prints_only_off_stage(monkeypatch, capsys):
    monkeypatch.delenv("MERCURY_CONFIG_DIR", raising=False)
    assert not staging.on_stage()
    staging.backstage("visible")
    assert capsys.readouterr().out == "visible\n"

    monkeypatch.setenv("MERCURY_CONFIG_DIR", "/tmp/app")
    assert staging.on_stage()
    staging.backstage("hidden")
    assert capsys.readouterr().out == ""
