Skip to content

Commit c21c42b

Browse files
committed
test(cli): create the non-ASCII Windows profile through the wide API
The Windows regression test for DeusData#2145 created its profile directory with test_mkdirp and read the result as a boolean. test_mkdirp returns 0 on success, so the test failed as soon as the directory existed and never reached the detection it was written to check. Inverting the check is not enough on its own. test_mkdirp uses cbm_mkdir, which is the narrow _mkdir on Windows. Under an ANSI code page such as 1252 it does not create the intended name: it creates a directory whose name is the UTF-8 bytes read as code-page characters. The old narrow stat finds that mangled directory and the new wide lookup correctly does not, so the test would pass without the fix and fail with it. th_mkdir_p goes through the wide API and creates the real name, the way a non-ASCII Windows profile actually looks. Since 2b329fe, Claude Code is detected from settings.json, .claude.json or the claude CLI, through cbm_file_exists, which is already wide on Windows; a bare .claude directory no longer marks it as detected. The test now asserts Cursor, which is detected by its directory alone, so the assertion goes through dir_exists, the function this branch changes. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent a36c692 commit c21c42b

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎tests/test_cli.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14597,19 +14597,24 @@ TEST(cli_detect_agents_finds_zed_in_roaming_appdata) {
1459714597
#endif
1459814598

1459914599
#ifdef _WIN32
14600+
/* #2145: a profile path outside the ANSI code page must stay visible to agent
14601+
* detection. The directory is created with th_mkdir_p, which goes through the
14602+
* wide-char API: test_mkdirp uses cbm_mkdir, the narrow _mkdir on Windows,
14603+
* which would create a code-page-mangled name instead of this one. Cursor is
14604+
* detected by its directory alone, so the assertion goes through dir_exists. */
1460014605
TEST(cli_detect_agents_handles_non_ascii_windows_profile) {
1460114606
char home[1024];
1460214607
snprintf(home, sizeof(home), "%s/cbm-用户-profile", cbm_tmpdir());
1460314608
test_rmdir_r(home);
14604-
char claude_dir[1024];
14605-
snprintf(claude_dir, sizeof(claude_dir), "%s/.claude", home);
14606-
if (!test_mkdirp(claude_dir))
14609+
char cursor_dir[1024];
14610+
snprintf(cursor_dir, sizeof(cursor_dir), "%s/.cursor", home);
14611+
if (th_mkdir_p(cursor_dir) != 0)
1460714612
FAIL("could not create non-ASCII Windows profile path");
1460814613

1460914614
cbm_detected_agents_t agents = cbm_detect_agents(home);
1461014615
test_rmdir_r(home);
14611-
if (!agents.claude_code)
14612-
FAIL("Claude detection must support non-ASCII Windows profile paths");
14616+
if (!agents.cursor)
14617+
FAIL("agent detection must support non-ASCII Windows profile paths");
1461314618
PASS();
1461414619
}
1461514620
#endif

0 commit comments

Comments
 (0)