Skip to content

fix(test): handle non-ASCII project paths in ShellCommandToolTest#1411

Open
YunKuiLu wants to merge 1 commit into
agentscope-ai:mainfrom
YunKuiLu:fix-test
Open

fix(test): handle non-ASCII project paths in ShellCommandToolTest#1411
YunKuiLu wants to merge 1 commit into
agentscope-ai:mainfrom
YunKuiLu:fix-test

Conversation

@YunKuiLu
Copy link
Copy Markdown

@YunKuiLu YunKuiLu commented May 16, 2026

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

  • Verified: mvn test -f agentscope-core/pom.xml -Dtest="ShellCommandToolTest\$BufferDeadlockTests#reproduceLargeFileCatDeadlockWithTestResource" passes
  • Spotless formatting check passes

URL.getPath() returns URL-encoded path which breaks shell command
execution when project directory contains non-ASCII characters (e.g.
Chinese). Use Paths.get(url.toURI()).toString() instead to properly
decode the resource path.
@YunKuiLu YunKuiLu requested a review from a team May 16, 2026 10:53
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant