Coverage for tests / unit_tests / commands / test_apio_raw.py: 100%
24 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-24 01:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-24 01:53 +0000
1"""Test for the "apio raw" command."""
3from tests.conftest import ApioRunner
4from apio.commands.apio import apio_top_cli as apio
7def test_raw(apio_runner: ApioRunner):
8 """Test "apio raw" with different parameters"""
10 with apio_runner.in_sandbox() as sb:
12 # -- NOTE: We run the apio raw command in a sub process to have a
13 # -- proper sys.argv for it for the '--' separator validation.
15 # -- Execute "apio raw"
16 result = sb.invoke_apio_cmd(apio, ["raw"], in_subprocess=True)
17 assert result.exit_code != 0, result.output
18 assert (
19 "at least one of --verbose or COMMAND must be specified"
20 in result.output
21 )
23 # -- Execute "apio raw -v"
24 result = sb.invoke_apio_cmd(apio, ["raw", "-v"], in_subprocess=True)
25 sb.assert_result_ok(result)
26 assert "Environment settings:" in result.output
27 assert "PATH" in result.output
28 assert "YOSYS_LIB" in result.output
30 # -- Run 'apio raw "nextpnr-ice40 --help"'.
31 result = sb.invoke_apio_cmd(
32 apio, ["raw", "--", "nextpnr-ice40", "--help"], in_subprocess=True
33 )
34 sb.assert_result_ok(result, bad_words=[])
36 # -- Run a command without the required '--'
37 result = sb.invoke_apio_cmd(
38 apio, ["raw", "nextpnr-ice40"], in_subprocess=True
39 )
40 assert result.exit_code != 0, result.output
41 assert "command separator '--' was not found" in result.output
43 # -- Run a command with a token before the '--' separator.
44 result = sb.invoke_apio_cmd(
45 apio, ["raw", "nextpnr-ice40", "--", "--help"], in_subprocess=True
46 )
47 assert result.exit_code != 0, result.output
48 assert "Invalid arguments: ['nextpnr-ice40']" in result.output
50 # -- Run 'apio raw -v'
51 result = sb.invoke_apio_cmd(apio, ["raw", "-v"], in_subprocess=True)
52 sb.assert_result_ok(result)
53 assert "Environment settings:" in result.output
54 assert "YOSYS_LIB" in result.output