Coverage for tests/unit_tests/commands/test_apio_info.py: 100%
61 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-07 05:08 +0000
1# This file is part of the Apio project
2# (C) 2016-present FPGAwars
3# Project authors:
4# * Jesús Arroyo (Jesus89) (2016-2019)
5# * Juan Gonzalez (obijuan) (2019-2024)
6# * The Apio Team (2024-present)
7# License: GPLv2
9"""Test for the "apio system" command."""
11import re
12from tests.conftest import ApioRunner
13from apio.commands.apio import apio_top_cli as apio
14from apio.common.apio_console import cunstyle, cwidth
17def test_apio_info(apio_runner: ApioRunner):
18 """Test 'apio info'"""
20 with apio_runner.in_sandbox() as sb:
21 # -- For debugging table column truncation in github testing.
22 print(f"Apio console width = {cwidth()}")
24 # -- Execute "apio info"
25 result = sb.invoke_apio_cmd(apio, ["info"])
26 sb.assert_result_ok(result)
27 assert "system" in result.output
28 assert "platforms" in result.output
29 assert "commands" in result.output
32def test_apio_info_system(apio_runner: ApioRunner):
33 """Test 'apio info system'"""
35 with apio_runner.in_sandbox() as sb:
36 # -- For debugging table column truncation in github testing.
37 print(f"Apio console width = {cwidth()}")
39 # -- Execute "apio info system"
40 result = sb.invoke_apio_cmd(apio, ["info", "system"])
41 sb.assert_result_ok(result)
42 assert "Platform id" in result.output
43 assert "Apio definitions dir" in result.output
44 # -- The these env options are set by the apio text fixture. We
45 # -- relax the expression to allow additional env vars that are
46 # -- injected to the test such as APIO_REMOTE_URL_CONFIG
47 assert re.search(
48 r"Active env options \[[^]]*APIO_HOME[^]]*\]", result.output
49 )
52def test_apio_info_project(apio_runner: ApioRunner):
53 """Test 'apio info project'"""
55 with apio_runner.in_sandbox() as sb:
56 # -- For debugging table column truncation in github testing.
57 print(f"Apio console width = {cwidth()}")
59 # -- Execute "apio examples fetch alhambra-ii/blinky"
60 # -- This will create a valid project in the current directory.
61 result = sb.invoke_apio_cmd(
62 apio, ["examples", "fetch", "alhambra-ii/blinky"]
63 )
64 sb.assert_result_ok(result)
65 assert "'alhambra-ii/blinky' fetched successfully" in result.output
67 # -- Execute "apio info project"
68 result = sb.invoke_apio_cmd(apio, ["info", "project"])
69 sb.assert_result_ok(result)
70 assert re.search(r"Active project env.*│.*default", result.output)
73def test_apio_info_platforms(apio_runner: ApioRunner):
74 """Test "apio info platforms'"""
76 with apio_runner.in_sandbox() as sb:
77 # -- For debugging table column truncation in github testing.
78 print(f"Apio console width = {cwidth()}")
80 # -- Execute "apio info platforms"
81 result = sb.invoke_apio_cmd(apio, ["info", "platforms"])
82 sb.assert_result_ok(result)
83 assert "darwin-arm64" in result.output
84 assert "Mac OSX" in result.output
85 assert "ARM 64 bit (Apple Silicon)" in result.output
88def test_apio_info_colors(apio_runner: ApioRunner):
89 """Test 'apio info colors'"""
91 with apio_runner.in_sandbox() as sb:
92 # -- For debugging table column truncation in github testing.
93 print(f"Apio console width = {cwidth()}")
95 # -- Execute "apio info colors"
96 result = sb.invoke_apio_cmd(apio, ["info", "colors"])
97 sb.assert_result_ok(result)
98 assert result.output != cunstyle(result.output) # Colored
99 assert "ANSI Colors" in result.output
100 assert "\x1b[31m 1 red \x1b[0m" in result.output
103def test_apio_info_themes(apio_runner: ApioRunner):
104 """Test 'apio info theme'"""
106 with apio_runner.in_sandbox() as sb:
107 # -- For debugging table column truncation in github testing.
108 print(f"Apio console width = {cwidth()}")
110 # -- Execute "apio info themes"
111 result = sb.invoke_apio_cmd(apio, ["info", "themes"])
112 # -- It's normal to have 'error' in the output text.
113 sb.assert_result_ok(result, bad_words=[])
114 assert result.output != cunstyle(result.output) # Colored
115 assert "NO-COLORS" in result.output
116 assert "apio.cmd_name\x1b[0m" in result.output
119def test_apio_info_commands(apio_runner: ApioRunner):
120 """Test 'apio commands'"""
122 with apio_runner.in_sandbox() as sb:
123 # -- For debugging table column truncation in github testing.
124 print(f"Apio console width = {cwidth()}")
126 # -- Execute "apio info commands"
127 result = sb.invoke_apio_cmd(apio, ["info", "commands"])
128 sb.assert_result_ok(result)
129 assert " build " in cunstyle(result.output)
130 assert "Synthesize the bitstream." in result.output
131 assert "[build](cmd-apio-build.md)" not in result.output