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:
Carles Cufi 2018-11-23 14:14:08 +01:00 committed by Marti Bolivar
parent cb5f2108a8
commit a0bc48342e
3 changed files with 70 additions and 14 deletions

View File

@ -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

View File

@ -127,6 +127,45 @@ def test_path():
assert manifest.projects[0].path == 'sub/directory' assert manifest.projects[0].path == 'sub/directory'
assert manifest.projects[0].abspath == os.path.realpath('/west_top/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. # Invalid manifests should raise MalformedManifest.
@pytest.mark.parametrize('invalid', @pytest.mark.parametrize('invalid',

View File

@ -294,14 +294,17 @@ def test_update(clean_west_topdir):
[manifest] [manifest]
remote = {0}/remote-repos/manifest remote = {0}/remote-repos/manifest
revision = master revision = master
[west]
remote = {0}/remote-repos/west
revision = master
'''.format(clean_west_topdir)) '''.format(clean_west_topdir))
config.read_config() 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 # Fetch the net-tools repository
cmd('fetch --no-update net-tools') cmd('fetch --no-update net-tools')
@ -360,16 +363,10 @@ def test_bootstrap_reinit(clean_west_topdir, monkeypatch):
bootstrap.init([]) # West already initialized bootstrap.init([]) # West already initialized
for init_args, west_args in ( for init_args, west_args in (
(['-m', 'foo'], ['update', '--reset-manifest', '--reset-projects']), (['-m', 'foo'], ['update', '--reset-manifest', '--reset-projects',
(['--mr', 'foo'], ['update', '--reset-manifest', '--reset-projects']), '--reset-west']),
(['-w', 'foo'], ['update', '--reset-west']), (['--mr', 'foo'], ['update', '--reset-manifest', '--reset-projects',
(['--wr', 'foo'], ['update', '--reset-west']), '--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'], [])):
# Reset wrap_args before each test so that it ends up as [] if wrap() # Reset wrap_args before each test so that it ends up as [] if wrap()
# isn't called (for the --no-reset case) # isn't called (for the --no-reset case)