Skip to content

Commit a80e090

Browse files
authored
fix(test): handle non-ASCII project paths in ShellCommandToolTest (#1411)
## Summary - Fix `reproduceLargeFileCatDeadlockWithTestResource` test failure when the project directory contains non-ASCII characters (e.g. Chinese characters like `工程`) ## Root Cause `URL.getPath()` returns URL-encoded paths (e.g. `%E5%AD%A6%E4%B9%A0`). When this encoded path is passed to `sh -c "cat ..."`, the shell treats the percent-encoded characters as literal characters and cannot find the file, causing the test to fail with a non-zero return code. ## Fix Replace `getClass().getClassLoader().getResource("large_output_test.txt").getPath()` with `Paths.get(getClass().getClassLoader().getResource("large_output_test.txt").toURI()).toString()` to properly decode the URI into a valid filesystem path. ## Test Plan - [x] Verified: `mvn test -f agentscope-core/pom.xml -Dtest="ShellCommandToolTest\$BufferDeadlockTests#reproduceLargeFileCatDeadlockWithTestResource"` passes - [x] Spotless formatting check passes
1 parent 46c94fc commit a80e090

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

agentscope-core/src/test/java/io/agentscope/core/tool/coding/ShellCommandToolTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,17 @@ void reproduceLargeFileCatDeadlock() throws Exception {
873873
@Test
874874
@DisplayName("Should handle pre-created large test file without deadlock")
875875
@EnabledOnOs({OS.LINUX, OS.MAC})
876-
void reproduceLargeFileCatDeadlockWithTestResource() {
876+
void reproduceLargeFileCatDeadlockWithTestResource() throws Exception {
877877
// Use the pre-created test resource file (20KB)
878+
// Use Paths.get(url.toURI()) instead of url.getPath() to properly decode
879+
// URL-encoded characters (e.g. Chinese characters in project path)
878880
String resourcePath =
879-
getClass().getClassLoader().getResource("large_output_test.txt").getPath();
881+
Paths.get(
882+
getClass()
883+
.getClassLoader()
884+
.getResource("large_output_test.txt")
885+
.toURI())
886+
.toString();
880887
String command = "cat " + resourcePath;
881888

882889
// Set a reasonable timeout - should complete quickly with the fix

0 commit comments

Comments
 (0)