2025-07-15 20:45:53 -07:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
2021-02-04 14:27:54 -05:00
|
|
|
import pytest
|
|
|
|
|
|
2025-07-15 20:45:53 -07:00
|
|
|
from cibuildwheel.logger import BuildInfo, Logger
|
|
|
|
|
from cibuildwheel.options import CommandLineArguments, Options
|
|
|
|
|
|
|
|
|
|
OPTIONS_DEFAULTS = Options("linux", CommandLineArguments.defaults(), {}, defaults=True)
|
|
|
|
|
FILE = Path(__file__)
|
2021-02-04 14:27:54 -05:00
|
|
|
|
|
|
|
|
|
2025-07-15 20:45:53 -07:00
|
|
|
def test_printout_wheels(capsys):
|
|
|
|
|
log = Logger()
|
|
|
|
|
log.fold_mode = "disabled"
|
|
|
|
|
log.colors_enabled = False
|
|
|
|
|
|
|
|
|
|
with log.print_summary(options=OPTIONS_DEFAULTS):
|
2025-07-26 13:13:01 +02:00
|
|
|
# the number of BuildInfo with & without filename shall be different for this test
|
2025-07-15 20:45:53 -07:00
|
|
|
log.summary = [
|
|
|
|
|
BuildInfo(identifier="id1", filename=None, duration=3),
|
|
|
|
|
BuildInfo(identifier="id2", filename=FILE, duration=2),
|
2025-07-26 13:13:01 +02:00
|
|
|
BuildInfo(identifier="id3", filename=FILE, duration=3),
|
2025-07-15 20:45:53 -07:00
|
|
|
]
|
2021-02-04 14:27:54 -05:00
|
|
|
|
|
|
|
|
captured = capsys.readouterr()
|
|
|
|
|
assert captured.err == ""
|
|
|
|
|
|
2025-07-15 20:45:53 -07:00
|
|
|
assert "id1" in captured.out
|
|
|
|
|
assert "id2" in captured.out
|
2025-07-26 13:13:01 +02:00
|
|
|
assert "id3" in captured.out
|
|
|
|
|
assert "2 wheels produced in" in captured.out
|
2025-07-15 20:45:53 -07:00
|
|
|
assert "SHA256=" in captured.out
|
2021-02-04 14:27:54 -05:00
|
|
|
|
|
|
|
|
|
2025-07-15 20:45:53 -07:00
|
|
|
def test_no_printout_on_error(capsys):
|
|
|
|
|
log = Logger()
|
|
|
|
|
with pytest.raises(RuntimeError), log.print_summary(options=OPTIONS_DEFAULTS):
|
2023-01-30 15:53:44 -05:00
|
|
|
raise RuntimeError()
|
2021-02-04 14:27:54 -05:00
|
|
|
|
2024-10-22 10:16:59 -04:00
|
|
|
captured = capsys.readouterr()
|
2021-02-04 14:27:54 -05:00
|
|
|
assert captured.err == ""
|
2025-07-15 20:45:53 -07:00
|
|
|
assert captured.out == ""
|