Skip to content

fix: resolve broker test's source path through PackageInfo instead of hardcoded Assets/unity-mcp#31

Open
dehuaichendragonplus wants to merge 1 commit into
FunplayAI:mainfrom
dehuaichendragonplus:fix/broker-tests-hardcoded-assets-path
Open

fix: resolve broker test's source path through PackageInfo instead of hardcoded Assets/unity-mcp#31
dehuaichendragonplus wants to merge 1 commit into
FunplayAI:mainfrom
dehuaichendragonplus:fix/broker-tests-hardcoded-assets-path

Conversation

@dehuaichendragonplus

Copy link
Copy Markdown
Contributor

What changed

  • 8 of the 61 EditMode tests in MCPBrokerTransportTests hardcoded the broker source path as Assets/unity-mcp/Editor/MCP/Server/Broker/keepalive-broker.cs.txt, which only exists when this repo's own source is checked out directly under Assets/. They always failed in any project that installs the package as a real UPM package (embedded, git, or registry), where the source lives under Packages/<name> or Library/PackageCache/<name>@version instead.
  • Both the filesystem lookup (ResolveBrokerSourcePath, used by 7 tests via CreateBrokerPaths) and the AssetDatabase lookup (BrokerSource_IsVisibleToAssetDatabaseForUnityPackageExport) now resolve through PackageInfo.FindForAssembly first, falling back to the old Assets/unity-mcp path only when the assembly isn't part of a package (preserving this repo's own dev-checkout layout).

Checklist

  • I tested the package in a clean Unity 2022.3+ project (tested live in a Unity 6000.3.13f1 project with the package embedded at Packages/com.gamebooom.unity.mcp)
  • I verified Funplay > MCP Server opens and starts correctly (N/A to this change)
  • If I changed setup, update, or config flows, I verified the affected flow end-to-end (N/A)
  • I updated docs for any user-facing behavior changes (test-only fix, no user-facing doc changes needed)
  • I did not commit local junk such as .idea/ or .DS_Store
  • I updated CHANGELOG.md when the change affects users

Verification note

Unity's own async Test Runner job tracking (run_tests/get_test_job, exposed via the Funplay MCP tools this repo builds) got stuck mid-run on EditMode tests in this large consumer project regardless of which tests were selected -- possibly an unrelated pre-existing issue with the job-tracking wrapper in bigger projects, worth a separate look. Verified this fix directly instead: reproduced ResolveBrokerSourcePath's and the AssetDatabase lookup's exact logic against the real embedded-package layout and confirmed both resolve correctly, where the old hardcoded path resolved to a nonexistent file.

… hardcoded Assets/unity-mcp

8 of the 61 EditMode tests in MCPBrokerTransportTests assumed this repo's own
Assets/unity-mcp dev-checkout layout and failed in any project that installs
the package as a real UPM package (embedded/git/registry), where the source
lives under Packages/<name> or Library/PackageCache/<name>@Version instead.

Verified in a real consumer project (embedded package): the old hardcoded
path resolved to a nonexistent file, the new PackageInfo.FindForAssembly-based
resolution finds the real file on disk and via AssetDatabase.
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