diff --git a/tests/manifests/invalid_submodule_no_path.yml b/tests/manifests/invalid_submodule_no_path.yml new file mode 100644 index 00000000..d0df5121 --- /dev/null +++ b/tests/manifests/invalid_submodule_no_path.yml @@ -0,0 +1,10 @@ +# Submodule entries require a path +manifest: + remotes: + - name: remote1 + url-base: https://example.com + projects: + - name: project1 + remote: remote1 + submodules: + - name: project2 diff --git a/tests/test_manifest.py b/tests/test_manifest.py index bae75bf0..9928af4e 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -3176,6 +3176,74 @@ def setup_project(name, group_filter): assert hasattr(m, '_legacy_group_filter_warned') +def test_submodule_manifest(): + m = M('''\ + projects: + - name: project1 + url: url + - name: project2 + url: url + submodules: true + - name: project3 + url: url + submodules: + - path: path + - name: project4 + url: url + submodules: + - path: path + name: subproject1 + - name: project5 + url: url + submodules: + - path: path + name: subproject1 + - path: path + name: subproject2 + - name: project6 + url: url + submodules: false + ''').as_dict()['manifest'] + + mp = m['projects'][0] + assert 'submodules' not in mp + + mp = m['projects'][1] + assert 'submodules' in mp + assert isinstance(mp['submodules'], bool) + assert mp['submodules'] + + mp = m['projects'][2] + assert isinstance(mp['submodules'], list) + assert len(mp['submodules']) == 1 + assert 'path' in mp['submodules'][0] + assert mp['submodules'][0]['path'] == 'path' + assert 'name' not in mp['submodules'][0] + + mp = m['projects'][3] + assert isinstance(mp['submodules'], list) + assert len(mp['submodules']) == 1 + assert 'path' in mp['submodules'][0] + assert mp['submodules'][0]['path'] == 'path' + assert 'name' in mp['submodules'][0] + assert mp['submodules'][0]['name'] == 'subproject1' + + mp = m['projects'][4] + assert isinstance(mp['submodules'], list) + assert len(mp['submodules']) == 2 + assert 'path' in mp['submodules'][0] + assert mp['submodules'][0]['path'] == 'path' + assert 'name' in mp['submodules'][0] + assert mp['submodules'][0]['name'] == 'subproject1' + assert 'path' in mp['submodules'][1] + assert mp['submodules'][1]['path'] == 'path' + assert 'name' in mp['submodules'][1] + assert mp['submodules'][1]['name'] == 'subproject2' + + mp = m['projects'][5] + assert 'submodules' not in mp + + ######################################### # Various invalid manifests