Coverage for tests / unit_tests / commands / test_apio_info.py: 100%

42 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-24 01:53 +0000

1"""Test for the "apio system" command.""" 

2 

3import re 

4from tests.conftest import ApioRunner 

5from apio.commands.apio import apio_top_cli as apio 

6from apio.common.apio_console import cunstyle, cwidth 

7 

8 

9def test_apio_info(apio_runner: ApioRunner): 

10 """Test "apio info" with different parameters""" 

11 

12 with apio_runner.in_sandbox() as sb: 

13 # -- For debugging table column truncation in github testing. 

14 print(f"Apio console width = {cwidth()}") 

15 

16 # -- Execute "apio info" 

17 result = sb.invoke_apio_cmd(apio, ["info"]) 

18 sb.assert_result_ok(result) 

19 assert "platforms" in result.output 

20 

21 # -- Execute "apio info system" 

22 result = sb.invoke_apio_cmd(apio, ["info", "system"]) 

23 sb.assert_result_ok(result) 

24 assert "Platform id" in result.output 

25 # -- The these env options are set by the apio text fixture. We 

26 # -- relax the expression to allow additional env vars that are 

27 # -- injected to the test such as APIO_REMOTE_URL_CONFIG 

28 assert re.search( 

29 r"Active env options \[[^]]*APIO_HOME[^]]*\]", result.output 

30 ) 

31 

32 # -- Execute "apio info platforms" 

33 result = sb.invoke_apio_cmd(apio, ["info", "platforms"]) 

34 sb.assert_result_ok(result) 

35 assert "darwin-arm64" in result.output 

36 assert "Mac OSX" in result.output 

37 assert "ARM 64 bit (Apple Silicon)" in result.output 

38 

39 # -- Execute "apio info commands" 

40 result = sb.invoke_apio_cmd(apio, ["info", "commands"]) 

41 sb.assert_result_ok(result) 

42 assert " build " in cunstyle(result.output) 

43 assert "Synthesize the bitstream." in result.output 

44 assert "[build](cmd-apio-build.md)" not in result.output 

45 

46 # -- Execute "apio info commands --docs" 

47 result = sb.invoke_apio_cmd(apio, ["info", "commands", "--docs"]) 

48 sb.assert_result_ok(result) 

49 assert "[build](cmd-apio-build.md)" in result.output 

50 assert "Synthesize the bitstream." in result.output 

51 assert " build " not in cunstyle(result.output) 

52 

53 # -- Execute "apio info colors" 

54 result = sb.invoke_apio_cmd(apio, ["info", "colors"]) 

55 sb.assert_result_ok(result) 

56 assert result.output != cunstyle(result.output) # Colored 

57 assert "ANSI Colors" in result.output 

58 assert "\x1b[31m 1 red \x1b[0m" in result.output 

59 

60 # -- Execute "apio info themes" 

61 result = sb.invoke_apio_cmd(apio, ["info", "themes"]) 

62 # -- It's normal to have 'error' in the output text. 

63 sb.assert_result_ok(result, bad_words=[]) 

64 assert result.output != cunstyle(result.output) # Colored 

65 assert "NO-COLORS" in result.output 

66 assert "apio.cmd_name\x1b[0m" in result.output 

67 

68 # -- Execute "apio info system". It should not emit colors. 

69 result = sb.invoke_apio_cmd(apio, ["info", "system"]) 

70 sb.assert_result_ok(result) 

71 assert result.output != cunstyle(result.output) # Colored