Skip to content

Commit

Permalink
tests: Add tests for manifest --freeze and submodules
Browse files Browse the repository at this point in the history
Add a minimal testing to validate submodule output for manifest --freeze

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
  • Loading branch information
pdgendt committed Sep 23, 2024
1 parent 7b28a7f commit 6dcc76d
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
path: subdir/Kconfiglib
groups:
- Kconfiglib-group
submodules: true
- name: tagged_repo
revision: v1.0
- name: net-tools
Expand Down Expand Up @@ -189,6 +190,7 @@ def repos_tmpdir(tmpdir, _session_repos):
- name: Kconfiglib
revision: zephyr
path: subdir/Kconfiglib
submodules: true
- name: tagged_repo
revision: v1.0
- name: net-tools
Expand Down
77 changes: 73 additions & 4 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def _list_f(format):
return ['list', '-f', format]


def _match_multiline_regex(expected, actual):
for eline_re, aline in zip(expected, actual):
assert re.match(eline_re, aline) is not None, (aline, eline_re)


def test_workspace(west_update_tmpdir):
# Basic test that west_update_tmpdir bootstrapped correctly. This
# is a basic test of west init and west update.
Expand Down Expand Up @@ -251,6 +256,7 @@ def test_manifest_freeze(west_update_tmpdir):
'^ path: subdir/Kconfiglib$',
'^ groups:$',
'^ - Kconfiglib-group$',
'^ submodules: true$',
'^ - name: tagged_repo$',
'^ url: .*$',
'^ revision: [a-f0-9]{40}$',
Expand All @@ -262,10 +268,7 @@ def test_manifest_freeze(west_update_tmpdir):
'^ west-commands: scripts/west-commands.yml$',
'^ self:$',
'^ path: zephyr$']

for eline_re, aline in zip(expected_res, actual):
assert re.match(eline_re, aline) is not None, (aline, eline_re)

_match_multiline_regex(expected_res, actual)

def test_compare(config_tmpdir, west_init_tmpdir):
# 'west compare' with no projects cloned should still work,
Expand Down Expand Up @@ -806,6 +809,26 @@ def test_update_submodules_list(repos_tmpdir):
capture_stderr=True, capture_stdout=True)
assert not (res.returncode or res.stdout.strip())

# Test freeze output with submodules
# see test_manifest_freeze for details
actual = cmd('manifest --freeze', cwd=ws).splitlines()
expected_res = ['^manifest:$',
'^ projects:$',
'^ - name: zephyr$',
f'^ url: {re.escape(str(zephyr))}$',
'^ revision: [a-f0-9]{40}$',
'^ submodules:$',
'^ - path: tagged_repo$',
'^ - name: net-tools$',
f'^ url: {re.escape(str(net_tools))}$',
'^ revision: [a-f0-9]{40}$',
'^ submodules:$',
f'^ - path: {re.escape(str(kconfiglib_submodule))}$',
'^ name: Kconfiglib$',
'^ self:$',
'^ path: mp$']
_match_multiline_regex(expected_res, actual)

def test_update_all_submodules(repos_tmpdir):
# The west update command should not only update projects,
# but also its submodules. Test verifies whether setting submodules
Expand Down Expand Up @@ -899,6 +922,19 @@ def test_update_all_submodules(repos_tmpdir):
capture_stderr=True, capture_stdout=True)
assert not (res.returncode or res.stdout.strip())

# Test freeze output with submodules
# see test_manifest_freeze for details
actual = cmd('manifest --freeze', cwd=ws).splitlines()
expected_res = ['^manifest:$',
'^ projects:$',
'^ - name: zephyr$',
f'^ url: {re.escape(str(zephyr))}$',
'^ revision: [a-f0-9]{40}$',
'^ submodules: true$',
'^ self:$',
'^ path: mp$']
_match_multiline_regex(expected_res, actual)

def test_update_no_submodules(repos_tmpdir):
# Test verifies whether setting submodules value to boolean False does not
# result in updating project submodules.
Expand Down Expand Up @@ -969,6 +1005,18 @@ def test_update_no_submodules(repos_tmpdir):
capture_stderr=True, capture_stdout=True)
assert (res.returncode or res.stdout.strip())

# Test freeze output with submodules
# see test_manifest_freeze for details
actual = cmd('manifest --freeze', cwd=ws).splitlines()
expected_res = ['^manifest:$',
'^ projects:$',
'^ - name: zephyr$',
f'^ url: {re.escape(str(zephyr))}$',
'^ revision: [a-f0-9]{40}$',
'^ self:$',
'^ path: mp$']
_match_multiline_regex(expected_res, actual)

def test_update_submodules_strategy(repos_tmpdir):
# The west update command is able to update submodules using default
# checkout strategy or rebase strategy, selected by adding -r argument
Expand Down Expand Up @@ -1097,6 +1145,27 @@ def test_update_submodules_strategy(repos_tmpdir):
assert net_tools_project.sha('HEAD', cwd=kconfiglib_dst_dir) \
== kconfiglib_new_sha

# Test freeze output with submodules
# see test_manifest_freeze for details
actual = cmd('manifest --freeze', cwd=ws).splitlines()
expected_res = ['^manifest:$',
'^ projects:$',
'^ - name: zephyr$',
f'^ url: {re.escape(str(zephyr))}$',
'^ revision: [a-f0-9]{40}$',
'^ submodules:$',
'^ - path: tagged_repo$',
'^ name: tagged_repo$',
'^ - name: net-tools$',
f'^ url: {re.escape(str(net_tools))}$',
'^ revision: [a-f0-9]{40}$',
'^ submodules:$',
'^ - path: Kconfiglib$',
'^ name: Kconfiglib$',
'^ self:$',
'^ path: mp$']
_match_multiline_regex(expected_res, actual)

@pytest.mark.xfail
def test_update_submodules_relpath(tmpdir):
# Regression test for
Expand Down

0 comments on commit 6dcc76d

Please sign in to comment.