tests: Fix and add tests for west url/revision in manifest
After switching from command-line parameters to a special section in the manifest file, rework the tests so that they verify the new scheme of things and add a new invalid manifest that can be tested in order to verify that the schema qualification is working correctly. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
cb5f2108a8
commit
a0bc48342e
|
@ -0,0 +1,20 @@
|
|||
# The default West manifest file to be used for Zephyr.
|
||||
#
|
||||
|
||||
west:
|
||||
url: https://example.com
|
||||
revision: arevision
|
||||
invalidfield: thisfieldisinvalid
|
||||
|
||||
manifest:
|
||||
defaults:
|
||||
remote: upstream
|
||||
revision: master
|
||||
|
||||
remotes:
|
||||
- name: upstream
|
||||
url: https://example.com
|
||||
|
||||
projects:
|
||||
- name: zephyr
|
||||
revision: abranch
|
|
@ -127,6 +127,45 @@ def test_path():
|
|||
assert manifest.projects[0].path == 'sub/directory'
|
||||
assert manifest.projects[0].abspath == os.path.realpath('/west_top/sub/directory')
|
||||
|
||||
def test_sections():
|
||||
# Projects must be able to override their default paths.
|
||||
content_wrong_west = '''\
|
||||
west:
|
||||
url: https://example.com
|
||||
revision: abranch
|
||||
wrongfield: avalue
|
||||
manifest:
|
||||
remotes:
|
||||
- name: testremote
|
||||
url: https://example.com
|
||||
projects:
|
||||
- name: testproject
|
||||
remote: testremote
|
||||
path: sub/directory
|
||||
'''
|
||||
with patch('west.util.west_topdir', return_value=os.path.realpath('/west_top')):
|
||||
# Parsing manifest only, no exception raised
|
||||
manifest = Manifest.from_data(yaml.safe_load(content_wrong_west), 'manifest')
|
||||
assert manifest.projects[0].path == 'sub/directory'
|
||||
assert manifest.projects[0].abspath == os.path.realpath('/west_top/sub/directory')
|
||||
content_wrong_manifest = '''\
|
||||
west:
|
||||
url: https://example.com
|
||||
revision: abranch
|
||||
manifest:
|
||||
remotes:
|
||||
- name: testremote
|
||||
url: https://example.com
|
||||
projects:
|
||||
- name: testproject
|
||||
remote: testremote
|
||||
path: sub/directory
|
||||
'''
|
||||
with patch('west.util.west_topdir', return_value=os.path.realpath('/west_top')):
|
||||
# Parsing west section only, no exception raised
|
||||
manifest = Manifest.from_data(yaml.safe_load(content_wrong_manifest), 'west')
|
||||
assert manifest.westmeta.url == 'https://example.com'
|
||||
assert manifest.westmeta.revision == 'abranch'
|
||||
|
||||
# Invalid manifests should raise MalformedManifest.
|
||||
@pytest.mark.parametrize('invalid',
|
||||
|
|
|
@ -294,14 +294,17 @@ def test_update(clean_west_topdir):
|
|||
[manifest]
|
||||
remote = {0}/remote-repos/manifest
|
||||
revision = master
|
||||
|
||||
[west]
|
||||
remote = {0}/remote-repos/west
|
||||
revision = master
|
||||
'''.format(clean_west_topdir))
|
||||
|
||||
config.read_config()
|
||||
|
||||
# modify the manifest to point to another west
|
||||
clean_west_topdir.join('manifest.yml').write('''
|
||||
west:
|
||||
url: file://{}/remote-repos/west
|
||||
revision: master
|
||||
'''.format(clean_west_topdir), 'a')
|
||||
|
||||
# Fetch the net-tools repository
|
||||
cmd('fetch --no-update net-tools')
|
||||
|
||||
|
@ -360,16 +363,10 @@ def test_bootstrap_reinit(clean_west_topdir, monkeypatch):
|
|||
bootstrap.init([]) # West already initialized
|
||||
|
||||
for init_args, west_args in (
|
||||
(['-m', 'foo'], ['update', '--reset-manifest', '--reset-projects']),
|
||||
(['--mr', 'foo'], ['update', '--reset-manifest', '--reset-projects']),
|
||||
(['-w', 'foo'], ['update', '--reset-west']),
|
||||
(['--wr', 'foo'], ['update', '--reset-west']),
|
||||
(['--wr', 'foo'], ['update', '--reset-west']),
|
||||
(['-m', 'foo', '-w', 'foo'],
|
||||
['update', '--reset-manifest', '--reset-projects', '--reset-west']),
|
||||
(['-b', 'foo'],
|
||||
['update', '--reset-manifest', '--reset-projects', '--reset-west']),
|
||||
(['-b', 'foo', '--no-reset'], [])):
|
||||
(['-m', 'foo'], ['update', '--reset-manifest', '--reset-projects',
|
||||
'--reset-west']),
|
||||
(['--mr', 'foo'], ['update', '--reset-manifest', '--reset-projects',
|
||||
'--reset-west'])):
|
||||
|
||||
# Reset wrap_args before each test so that it ends up as [] if wrap()
|
||||
# isn't called (for the --no-reset case)
|
||||
|
|
Loading…
Reference in New Issue