|
5 | 5 | #include "../src/watcher/svn_state.h" |
6 | 6 | #include "test_helpers.h" |
7 | 7 |
|
| 8 | +#include <ctype.h> |
| 9 | + |
8 | 10 | typedef struct { |
9 | 11 | char root[CBM_SZ_4K]; |
10 | 12 | char repository[CBM_SZ_4K]; |
@@ -61,11 +63,29 @@ static inline int th_svn_fixture_init(th_svn_fixture_t *fixture, const char *pre |
61 | 63 | snprintf(normalized_repository, sizeof(normalized_repository), "%s", fixture->repository); |
62 | 64 | cbm_normalize_path_sep(normalized_repository); |
63 | 65 | char repository_url[CBM_SZ_8K]; |
| 66 | + int url_length; |
64 | 67 | #ifdef _WIN32 |
65 | | - snprintf(repository_url, sizeof(repository_url), "file:///%s", normalized_repository); |
| 68 | + /* The Windows CI installs MSYS2's POSIX Subversion build. It deliberately |
| 69 | + * treats file:///D:/... as the literal POSIX path /D:/..., so translate a |
| 70 | + * drive path to its MSYS mount. Native Windows Subversion keeps DOS URIs. */ |
| 71 | + bool msys_client = strstr(fixture->client.executable, "/usr/bin/svn.exe") != NULL; |
| 72 | + if (msys_client && isalpha((unsigned char)normalized_repository[0]) && |
| 73 | + normalized_repository[1] == ':' && normalized_repository[2] == '/') { |
| 74 | + url_length = |
| 75 | + snprintf(repository_url, sizeof(repository_url), "file:///%c%s", |
| 76 | + tolower((unsigned char)normalized_repository[0]), normalized_repository + 2); |
| 77 | + } else { |
| 78 | + url_length = |
| 79 | + snprintf(repository_url, sizeof(repository_url), "file:///%s", normalized_repository); |
| 80 | + } |
66 | 81 | #else |
67 | | - snprintf(repository_url, sizeof(repository_url), "file://%s", normalized_repository); |
| 82 | + url_length = |
| 83 | + snprintf(repository_url, sizeof(repository_url), "file://%s", normalized_repository); |
68 | 84 | #endif |
| 85 | + if (url_length < 0 || (size_t)url_length >= sizeof(repository_url)) { |
| 86 | + th_svn_fixture_cleanup(fixture); |
| 87 | + return -1; |
| 88 | + } |
69 | 89 | const char *checkout_args[] = {fixture->client.executable, "checkout", "--non-interactive", |
70 | 90 | repository_url, fixture->working_copy, NULL}; |
71 | 91 | if (cbm_exec_no_shell(checkout_args) != 0) { |
|
0 commit comments