|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | from codecov_cli.fallbacks import FallbackFieldEnum |
6 | | -from codecov_cli.helpers.versioning_systems import GitVersioningSystem |
| 6 | +from codecov_cli.helpers.versioning_systems import ( |
| 7 | + GitVersioningSystem, |
| 8 | + NoVersioningSystem, |
| 9 | +) |
7 | 10 |
|
8 | 11 |
|
9 | 12 | class TestGitVersioningSystem(object): |
@@ -105,8 +108,7 @@ def test_list_relevant_files_returns_correct_network_files(self, mocker, tmp_pat |
105 | 108 | "codecov_cli.helpers.versioning_systems.subprocess.run", |
106 | 109 | return_value=mocked_subprocess, |
107 | 110 | ) |
108 | | - # git ls-files diplays a single \n as \\\\n |
109 | | - mocked_subprocess.stdout = b'a.txt\nb.txt\n"a\\\\nb.txt"\nc.txt\nd.txt\n.circleci/config.yml\nLICENSE\napp/advanced calculations/advanced_calculator.js\n' |
| 111 | + mocked_subprocess.stdout = b"a.txt\0b.txt\0a\\nb.txt\0c.txt\0d.txt\0.circleci/config.yml\0LICENSE\0app/advanced calculations/advanced_calculator.js" |
110 | 112 |
|
111 | 113 | vs = GitVersioningSystem() |
112 | 114 |
|
@@ -138,6 +140,25 @@ def test_list_relevant_files_recurse_submodules(self, mocker, tmp_path): |
138 | 140 | vs = GitVersioningSystem() |
139 | 141 | _ = vs.list_relevant_files(tmp_path, recurse_submodules=True) |
140 | 142 | subproc_run.assert_called_with( |
141 | | - ["git", "-C", str(tmp_path), "ls-files", "--recurse-submodules"], |
| 143 | + ["git", "-C", str(tmp_path), "ls-files", "-z", "--recurse-submodules"], |
142 | 144 | capture_output=True, |
143 | 145 | ) |
| 146 | + |
| 147 | + |
| 148 | +def test_exotic_git_filenames(): |
| 149 | + vs = GitVersioningSystem() |
| 150 | + found_repo_files = vs.list_relevant_files() |
| 151 | + |
| 152 | + # See <https://github.com/codecov/codecov-action/issues/1550> |
| 153 | + assert ( |
| 154 | + "tests/data/Контроллеры/Пользователь/ГлавныйКонтроллер.php" in found_repo_files |
| 155 | + ) |
| 156 | + |
| 157 | + |
| 158 | +def test_exotic_fallback_filenames(): |
| 159 | + vs = NoVersioningSystem() |
| 160 | + found_repo_files = vs.list_relevant_files() |
| 161 | + |
| 162 | + assert ( |
| 163 | + "tests/data/Контроллеры/Пользователь/ГлавныйКонтроллер.php" in found_repo_files |
| 164 | + ) |
0 commit comments