Skip to content

Commit

Permalink
tests: add basic test for grep command
Browse files Browse the repository at this point in the history
Get some minimal coverage.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
  • Loading branch information
mbolivar-ampere committed Aug 30, 2023
1 parent 6d37174 commit 4c76e15
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,27 @@ def test_forall(west_init_tmpdir):
'foo',
]


def test_grep(west_init_tmpdir):
# Make sure we don't find things we don't expect, and do find
# things we do.

actual_no_update = cmd('grep net-').strip()
actual_no_update_lines = actual_no_update.splitlines()
assert len(actual_no_update_lines) == 2
assert re.fullmatch(r'=== manifest \(zephyr\):', actual_no_update_lines[0])
assert re.search('net-tools', actual_no_update_lines[1])

assert not re.search('hello', cmd('grep hello'))
cmd('update')
assert re.search('hello', cmd('grep hello'))

# Make sure '--' is handled properly: the first one is for
# west, and the second one is for the tool

assert re.search('west-commands', cmd('grep -- -- -commands'))


def test_update_projects(west_init_tmpdir):
# Test the 'west update' command. It calls through to the same backend
# functions that are used for automatic updates and 'west init'
Expand Down

0 comments on commit 4c76e15

Please sign in to comment.