Skip to content

Commit

Permalink
psh: add help command test
Browse files Browse the repository at this point in the history
JIRA: PD-77
  • Loading branch information
damianloew authored and mateusz-bloch committed Nov 7, 2023
1 parent f7ad295 commit 62dbbc2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions psh/test-help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Phoenix-RTOS
#
# phoenix-rtos-tests
#
# psh help command test
#
# Copyright 2023 Phoenix Systems
# Author: Damian Loewnau
#
# This file is part of Phoenix-RTOS.
#
# %LICENSE%
#

import psh.tools.psh as psh

# matches any line, for example - 'Available commands:'
INITIAL_LINE_PATTERN = rf'[^\r\n]+{psh.EOL}'
# matches command with any explanation + newline
HELP_LINE_PATTERN = rf'((\s*?)(?P<cmd>\w+)(\s+)-[^\r\n]+{psh.EOL})'


@psh.run
def harness(p):
# asserts that at least 15 help commands are displayed in proper format
psh.assert_cmd(p,
'help',
expected=rf'{INITIAL_LINE_PATTERN}{HELP_LINE_PATTERN}{{15,}}', is_regex=True)

# psh help does not fail when passing arguments
psh.assert_cmd(p,
'help -a arg1 --arg2 -arg3',
expected=rf'{INITIAL_LINE_PATTERN}{HELP_LINE_PATTERN}{{15,}}', is_regex=True)
3 changes: 3 additions & 0 deletions psh/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ test:

- name: history
harness: test-history.py

- name: help
harness: test-help.py

0 comments on commit 62dbbc2

Please sign in to comment.