Skip to content

Commit 0a93595

Browse files
committed
test_project.py: add test_list_special_chars()
Detect any unexpected changes in the way we've been handling backslashes and multiple slashes in paths. Changes in how we handle such edge cases may or may not be desired (and this test may be updated accordingly), but we never want these changes to come as a surprise and we want to keep control over them. This came up as part of the review for zephyrproject-rtos#920 which fixes zephyrproject-rtos#725
1 parent 1700666 commit 0a93595

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

tests/test_project.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
create_repo,
2626
create_workspace,
2727
rev_parse,
28+
yaml_editor,
2829
)
2930

3031
from west.manifest import ImportFlag as MIF
@@ -157,17 +158,47 @@ def test_list_manifest(west_update_tmpdir):
157158
abspath = cmd('list -f {abspath} manifest').strip()
158159
posixpath = cmd('list -f {posixpath} manifest').strip()
159160
assert path == 'manifest_moved'
160-
assert Path(abspath) == west_update_tmpdir / 'manifest_moved'
161+
assert abspath == str(west_update_tmpdir / 'manifest_moved')
161162
assert posixpath == Path(west_update_tmpdir).as_posix() + '/manifest_moved'
162163

163164
path = cmd('list --manifest-path-from-yaml -f {path} manifest').strip()
164165
abspath = cmd('list --manifest-path-from-yaml -f {abspath} manifest').strip()
165166
posixpath = cmd('list --manifest-path-from-yaml -f {posixpath} manifest').strip()
166167
assert path == 'zephyr'
167-
assert Path(abspath) == Path(str(west_update_tmpdir / 'zephyr'))
168+
assert abspath == str(west_update_tmpdir / 'zephyr')
168169
assert posixpath == Path(west_update_tmpdir).as_posix() + '/zephyr'
169170

170171

172+
def test_list_special_chars(west_update_tmpdir):
173+
# Detect any unexpected changes in the way we've been handling backslashes and multiple
174+
# slashes in paths. Changes in how we handle such edge cases may or may not be desired
175+
# (and this test may be updated accordingly), but we never want these changes to come as
176+
# a surprise and we want to keep control over them.
177+
178+
proj_name = 'net-tools2-stress-slashes'
179+
180+
with yaml_editor('zephyr/west.yml') as mf:
181+
mf["manifest"]["projects"].append(
182+
{
183+
'name': proj_name,
184+
'path': r'subdir///sub dir2\\\net-tools2',
185+
'url': mf["manifest"]["remotes"][0]["url-base"] + '/net-tools',
186+
'description': 'Test special chars in paths',
187+
},
188+
)
189+
print(cmd('diff')) # just logging
190+
191+
path = cmd('list -f {path} ' + proj_name).strip()
192+
abspath = cmd('list -f {abspath} ' + proj_name).strip()
193+
posixpath = cmd('list -f {posixpath} ' + proj_name).strip()
194+
195+
forward_rel_path = r'subdir/sub dir2/net-tools2' if WINDOWS else r'subdir/sub dir2\\\net-tools2'
196+
native_rel_path = r'subdir\sub dir2\net-tools2' if WINDOWS else r'subdir/sub dir2\\\net-tools2'
197+
assert path == forward_rel_path
198+
assert abspath == str(west_update_tmpdir) + os.path.sep + native_rel_path
199+
assert posixpath == Path(west_update_tmpdir).as_posix() + '/' + forward_rel_path
200+
201+
171202
def test_list_groups(west_init_tmpdir):
172203
with open('zephyr/west.yml', 'w') as f:
173204
f.write("""

0 commit comments

Comments
 (0)