tests: fixes for windows
The code being tested is fine; there are just issues in the test cases which make them fail on Windows. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
ae784d516d
commit
0d1dfa523f
|
@ -72,6 +72,9 @@ def check_proj_consistency(actual, expected):
|
|||
assert actual.revision == expected.revision
|
||||
assert actual.west_commands == expected.west_commands
|
||||
|
||||
def nodrive(path):
|
||||
return os.path.splitdrive(path)[1]
|
||||
|
||||
def test_init_with_url():
|
||||
# Test the project constructor works as expected with a URL.
|
||||
|
||||
|
@ -81,9 +84,7 @@ def test_init_with_url():
|
|||
assert p.path == 'p'
|
||||
assert p.topdir is None
|
||||
assert p.abspath is None
|
||||
if platform.system() == 'Windows':
|
||||
posixpath = os.path.splitdrive(p.posixpath)[1]
|
||||
assert posixpath == '/west_top/p'
|
||||
assert p.posixpath is None
|
||||
assert p.clone_depth is None
|
||||
assert p.revision == 'master'
|
||||
assert p.west_commands is None
|
||||
|
@ -195,7 +196,7 @@ def test_manifest_attrs():
|
|||
assert mp.name == 'manifest'
|
||||
assert mp.path == 'my-path'
|
||||
assert mp.topdir is not None
|
||||
assert PurePath(mp.abspath) == PurePath('/west_top/my-path')
|
||||
assert PurePath(nodrive(mp.abspath)) == PurePath('/west_top/my-path')
|
||||
assert mp.posixpath is not None
|
||||
assert mp.west_commands == 'cmds.yml'
|
||||
assert mp.url is None
|
||||
|
@ -664,9 +665,10 @@ def test_path():
|
|||
remote: testremote
|
||||
path: sub/directory
|
||||
'''
|
||||
manifest = Manifest.from_data(yaml.safe_load(content), topdir='/west_top')
|
||||
assert manifest.projects[1].path == 'sub' + os.path.sep + 'directory'
|
||||
assert manifest.projects[1].posixpath == '/west_top/sub/directory'
|
||||
p = Manifest.from_data(yaml.safe_load(content),
|
||||
topdir='/west_top').projects[1]
|
||||
assert p.path == 'sub/directory'
|
||||
assert nodrive(p.posixpath) == '/west_top/sub/directory'
|
||||
|
||||
|
||||
def test_ignore_west_section():
|
||||
|
@ -693,7 +695,7 @@ def test_ignore_west_section():
|
|||
topdir='/west_top')
|
||||
p1 = manifest.projects[1]
|
||||
assert PurePath(p1.path) == PurePath('sub', 'directory')
|
||||
assert PurePath(p1.abspath) == PurePath('/west_top/sub/directory')
|
||||
assert PurePath(nodrive(p1.abspath)) == PurePath('/west_top/sub/directory')
|
||||
|
||||
def test_project_west_commands():
|
||||
# Projects may specify subdirectories containing west commands.
|
||||
|
|
|
@ -49,8 +49,7 @@ def test_list(west_update_tmpdir):
|
|||
# Check the behavior for some format arguments of interest as well.
|
||||
actual = cmd('list -f "{name} {revision} {path} {cloned} {clone_depth}"')
|
||||
expected = ['manifest HEAD zephyr cloned None',
|
||||
'Kconfiglib zephyr {} cloned None'.format(
|
||||
os.path.join('subdir', 'Kconfiglib')),
|
||||
'Kconfiglib zephyr subdir/Kconfiglib cloned None',
|
||||
'net-tools master net-tools cloned 1']
|
||||
assert actual.splitlines() == expected
|
||||
|
||||
|
@ -90,13 +89,12 @@ def test_manifest_freeze(west_update_tmpdir):
|
|||
# match project order as specified in our manifest, that all
|
||||
# revisions are full 40-character SHAs, and there isn't any random
|
||||
# YAML tag crap.
|
||||
kconfig_rel = os.path.join('subdir', 'Kconfiglib')
|
||||
expected_res = ['^manifest:$',
|
||||
'^ projects:$',
|
||||
'^ - name: Kconfiglib$',
|
||||
'^ url: .*$',
|
||||
'^ revision: [a-f0-9]{40}$',
|
||||
'^ path: {}$'.format(re.escape(kconfig_rel)),
|
||||
'^ path: subdir/Kconfiglib$',
|
||||
'^ - name: net-tools$',
|
||||
'^ url: .*$',
|
||||
'^ clone-depth: 1$',
|
||||
|
@ -357,8 +355,7 @@ def test_extension_command_multiproject(repos_tmpdir):
|
|||
# The newline shenanigans are for Windows.
|
||||
help_text = '\n'.join(cmd('-h').splitlines())
|
||||
expected = '\n'.join([
|
||||
'extension commands from project Kconfiglib (path: {}):'.
|
||||
format(os.path.join('subdir', 'Kconfiglib')),
|
||||
'extension commands from project Kconfiglib (path: subdir/Kconfiglib):', # noqa: E501
|
||||
' kconfigtest: (no help provided; try "west kconfigtest -h")', # noqa: E501
|
||||
'',
|
||||
'extension commands from project net-tools (path: net-tools):',
|
||||
|
|
Loading…
Reference in New Issue