-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ test: | |
|
||
- name: history | ||
harness: test-history.py | ||
|
||
- name: help | ||
harness: test-help.py |