Commit a80e090
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 passes1 parent 46c94fc commit a80e090
1 file changed
Lines changed: 9 additions & 2 deletions
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
876 | | - | |
| 876 | + | |
877 | 877 | | |
| 878 | + | |
| 879 | + | |
878 | 880 | | |
879 | | - | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
880 | 887 | | |
881 | 888 | | |
882 | 889 | | |
| |||
0 commit comments