The pyproject declared a freeroute script but freeroute.cli was missing, so the entry point was broken. Add it: reads a Specctra .dsn, routes (rip-up on by default), writes SES. Accepts FreeRouting-compatible -de/-do flags so it can be dropped in wherever 'java -jar freerouting.jar' was called.
38 lines
923 B
Python
38 lines
923 B
Python
"""Tests for the freeroute CLI (Specctra DSN in, SES out)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from freeroute.cli import main
|
|
|
|
FIXTURE = Path(__file__).parent / "dsn" / "fixtures" / "simple_2net.dsn"
|
|
|
|
|
|
def test_cli_jar_compatible_flags_write_ses(tmp_path):
|
|
out = tmp_path / "out.ses"
|
|
rc = main(["-de", str(FIXTURE), "-do", str(out)])
|
|
assert rc == 0
|
|
text = out.read_text()
|
|
assert text.startswith("(session")
|
|
assert "(net" in text and "(wire" in text
|
|
|
|
|
|
def test_cli_positional_input_to_stdout(capsys):
|
|
rc = main([str(FIXTURE)])
|
|
assert rc == 0
|
|
assert "(session" in capsys.readouterr().out
|
|
|
|
|
|
def test_cli_missing_input_errors():
|
|
with pytest.raises(SystemExit):
|
|
main([])
|
|
|
|
|
|
def test_cli_unreadable_input_returns_2(capsys):
|
|
rc = main(["/nonexistent/board.dsn"])
|
|
assert rc == 2
|
|
assert "cannot read" in capsys.readouterr().err
|