|
25 | 25 | create_repo, |
26 | 26 | create_workspace, |
27 | 27 | rev_parse, |
| 28 | + yaml_editor, |
28 | 29 | ) |
29 | 30 |
|
30 | 31 | from west.manifest import ImportFlag as MIF |
@@ -157,17 +158,47 @@ def test_list_manifest(west_update_tmpdir): |
157 | 158 | abspath = cmd('list -f {abspath} manifest').strip() |
158 | 159 | posixpath = cmd('list -f {posixpath} manifest').strip() |
159 | 160 | assert path == 'manifest_moved' |
160 | | - assert Path(abspath) == west_update_tmpdir / 'manifest_moved' |
| 161 | + assert abspath == str(west_update_tmpdir / 'manifest_moved') |
161 | 162 | assert posixpath == Path(west_update_tmpdir).as_posix() + '/manifest_moved' |
162 | 163 |
|
163 | 164 | path = cmd('list --manifest-path-from-yaml -f {path} manifest').strip() |
164 | 165 | abspath = cmd('list --manifest-path-from-yaml -f {abspath} manifest').strip() |
165 | 166 | posixpath = cmd('list --manifest-path-from-yaml -f {posixpath} manifest').strip() |
166 | 167 | assert path == 'zephyr' |
167 | | - assert Path(abspath) == Path(str(west_update_tmpdir / 'zephyr')) |
| 168 | + assert abspath == str(west_update_tmpdir / 'zephyr') |
168 | 169 | assert posixpath == Path(west_update_tmpdir).as_posix() + '/zephyr' |
169 | 170 |
|
170 | 171 |
|
| 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 | + |
171 | 202 | def test_list_groups(west_init_tmpdir): |
172 | 203 | with open('zephyr/west.yml', 'w') as f: |
173 | 204 | f.write(""" |
|
0 commit comments