From ae5ffe425278562c7e02f00435d2c71d1a04a6d0 Mon Sep 17 00:00:00 2001 From: Alex Hancock Date: Wed, 29 Oct 2025 11:59:34 -0400 Subject: [PATCH] fix(tests): don't use user specific paths in mcp integration tests --- crates/goose/tests/mcp_integration_test.rs | 15 +++++++++++---- ...--quiet-pgoose-server--bingoosed--mcpdeveloper | 14 +++++++------- ...e-server--bingoosed--mcpdeveloper.results.json | 8 ++++---- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/crates/goose/tests/mcp_integration_test.rs b/crates/goose/tests/mcp_integration_test.rs index e3c47a56524f..9182735a5863 100644 --- a/crates/goose/tests/mcp_integration_test.rs +++ b/crates/goose/tests/mcp_integration_test.rs @@ -108,22 +108,22 @@ enum TestMode { vec![ CallToolRequestParam { name: "text_editor".into(), arguments: Some(object!({ "command": "view", - "path": "~/goose/crates/goose/tests/tmp/goose.txt" + "path": "/tmp/goose_test/goose.txt" }))}, CallToolRequestParam { name: "text_editor".into(), arguments: Some(object!({ "command": "str_replace", - "path": "~/goose/crates/goose/tests/tmp/goose.txt", + "path": "/tmp/goose_test/goose.txt", "old_str": "# goose", "new_str": "# goose (modified by test)" }))}, // Test shell command to verify file was modified CallToolRequestParam { name: "shell".into(), arguments: Some(object!({ - "command": "cat ~/goose/crates/goose/tests/tmp/goose.txt" + "command": "cat /tmp/goose_test/goose.txt" })) }, // Test text_editor tool to restore original content CallToolRequestParam { name: "text_editor".into(), arguments: Some(object!({ "command": "str_replace", - "path": "~/goose/crates/goose/tests/tmp/goose.txt", + "path": "/tmp/goose_test/goose.txt", "old_str": "# goose (modified by test)", "new_str": "# goose" }))}, @@ -138,6 +138,13 @@ async fn test_replayed_session( required_envs: Vec<&str>, ) { std::env::set_var("GOOSE_MCP_CLIENT_VERSION", "0.0.0"); + + // Setup test file for developer extension tests + let test_file_path = "/tmp/goose_test/goose.txt"; + if let Some(parent) = std::path::Path::new(test_file_path).parent() { + fs::create_dir_all(parent).ok(); + } + fs::write(test_file_path, "# goose\n").ok(); let replay_file_name = command .iter() .map(|s| s.replace("/", "_")) diff --git a/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper b/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper index 1b6f4f54ec91..b8b5c12a217b 100644 --- a/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper +++ b/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper @@ -10,19 +10,19 @@ STDIN: {"jsonrpc":"2.0","method":"notifications/initialized"} STDERR: 2025-09-27T04:13:30.418172Z  INFO rmcp::handler::server: client initialized STDERR: at /Users/angiej/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rmcp-0.6.2/src/handler/server.rs:218 STDERR: -STDIN: {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"_meta":{"progressToken":0},"name":"text_editor","arguments":{"command":"view","path":"~/goose/crates/goose/tests/tmp/goose.txt"}}} +STDIN: {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"_meta":{"progressToken":0},"name":"text_editor","arguments":{"command":"view","path":"/tmp/goose_test/goose.txt"}}} STDERR: 2025-09-27T04:13:30.418412Z  INFO rmcp::service: Service initialized as server, peer_info: Some(InitializeRequestParam { protocol_version: ProtocolVersion("2025-03-26"), capabilities: ClientCapabilities { experimental: None, roots: None, sampling: None, elicitation: None }, client_info: Implementation { name: "goose", version: "1.9.0" } }) STDERR: at /Users/angiej/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rmcp-0.6.2/src/service.rs:561 STDERR: in rmcp::service::serve_inner STDERR: -STDOUT: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"resource","resource":{"uri":"file:///Users/angiej/goose/crates/goose/tests/tmp/goose.txt","mimeType":"text","text":"# goose\n"},"annotations":{"audience":["assistant"]}},{"type":"text","text":"### /Users/angiej/goose/crates/goose/tests/tmp/goose.txt\n```\n1: # goose\n```\n","annotations":{"audience":["user"],"priority":0.0}}],"isError":false}} -STDIN: {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"_meta":{"progressToken":1},"name":"text_editor","arguments":{"command":"str_replace","new_str":"# goose (modified by test)","old_str":"# goose","path":"~/goose/crates/goose/tests/tmp/goose.txt"}}} -STDOUT: {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"The file /Users/angiej/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# goose (modified by test)\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n","annotations":{"audience":["assistant"]}},{"type":"text","text":"```\n# goose (modified by test)\n```\n","annotations":{"audience":["user"],"priority":0.2}}],"isError":false}} -STDIN: {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"_meta":{"progressToken":2},"name":"shell","arguments":{"command":"cat ~/goose/crates/goose/tests/tmp/goose.txt"}}} +STDOUT: {"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"resource","resource":{"uri":"file:///tmp/goose_test/goose.txt","mimeType":"text","text":"# goose\n"},"annotations":{"audience":["assistant"]}},{"type":"text","text":"### /tmp/goose_test/goose.txt\n```\n1: # goose\n```\n","annotations":{"audience":["user"],"priority":0.0}}],"isError":false}} +STDIN: {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"_meta":{"progressToken":1},"name":"text_editor","arguments":{"command":"str_replace","new_str":"# goose (modified by test)","old_str":"# goose","path":"/tmp/goose_test/goose.txt"}}} +STDOUT: {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"The file /tmp/goose_test/goose.txt has been edited, and the section now reads:\n```\n# goose (modified by test)\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n","annotations":{"audience":["assistant"]}},{"type":"text","text":"```\n# goose (modified by test)\n```\n","annotations":{"audience":["user"],"priority":0.2}}],"isError":false}} +STDIN: {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"_meta":{"progressToken":2},"name":"shell","arguments":{"command":"cat /tmp/goose_test/goose.txt"}}} STDOUT: {"jsonrpc":"2.0","method":"notifications/message","params":{"level":"info","logger":"shell_tool","data":{"type":"shell_output","stream":"stdout","output":"# goose (modified by test)"}}} STDOUT: {"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"# goose (modified by test)\n","annotations":{"audience":["assistant"]}},{"type":"text","text":"# goose (modified by test)\n","annotations":{"audience":["user"],"priority":0.0}}],"isError":false}} -STDIN: {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"_meta":{"progressToken":3},"name":"text_editor","arguments":{"command":"str_replace","new_str":"# goose","old_str":"# goose (modified by test)","path":"~/goose/crates/goose/tests/tmp/goose.txt"}}} -STDOUT: {"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"The file /Users/angiej/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# goose\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n","annotations":{"audience":["assistant"]}},{"type":"text","text":"```\n# goose\n```\n","annotations":{"audience":["user"],"priority":0.2}}],"isError":false}} +STDIN: {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"_meta":{"progressToken":3},"name":"text_editor","arguments":{"command":"str_replace","new_str":"# goose","old_str":"# goose (modified by test)","path":"/tmp/goose_test/goose.txt"}}} +STDOUT: {"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"The file /tmp/goose_test/goose.txt has been edited, and the section now reads:\n```\n# goose\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n","annotations":{"audience":["assistant"]}},{"type":"text","text":"```\n# goose\n```\n","annotations":{"audience":["user"],"priority":0.2}}],"isError":false}} STDIN: {"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"_meta":{"progressToken":4},"name":"list_windows","arguments":{}}} STDOUT: {"jsonrpc":"2.0","id":5,"result":{"content":[{"type":"text","text":"Available windows:\nMenubar","annotations":{"audience":["assistant"]}},{"type":"text","text":"Available windows:\nMenubar","annotations":{"audience":["user"],"priority":0.0}}],"isError":false}} STDERR: 2025-09-27T04:13:30.505916Z  INFO rmcp::service: input stream terminated diff --git a/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper.results.json b/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper.results.json index c01cbec5f023..1f53d3c2629e 100644 --- a/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper.results.json +++ b/crates/goose/tests/mcp_replays/cargorun--quiet-pgoose-server--bingoosed--mcpdeveloper.results.json @@ -3,7 +3,7 @@ { "type": "resource", "resource": { - "uri": "file:///Users/angiej/goose/crates/goose/tests/tmp/goose.txt", + "uri": "file:///tmp/goose_test/goose.txt", "mimeType": "text", "text": "# goose\n" }, @@ -15,7 +15,7 @@ }, { "type": "text", - "text": "### /Users/angiej/goose/crates/goose/tests/tmp/goose.txt\n```\n1: # goose\n```\n", + "text": "### /tmp/goose_test/goose.txt\n```\n1: # goose\n```\n", "annotations": { "audience": [ "user" @@ -27,7 +27,7 @@ [ { "type": "text", - "text": "The file /Users/angiej/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# goose (modified by test)\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n", + "text": "The file /tmp/goose_test/goose.txt has been edited, and the section now reads:\n```\n# goose (modified by test)\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n", "annotations": { "audience": [ "assistant" @@ -69,7 +69,7 @@ [ { "type": "text", - "text": "The file /Users/angiej/goose/crates/goose/tests/tmp/goose.txt has been edited, and the section now reads:\n```\n# goose\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n", + "text": "The file /tmp/goose_test/goose.txt has been edited, and the section now reads:\n```\n# goose\n```\n\nReview the changes above for errors. Undo and edit the file again if necessary!\n", "annotations": { "audience": [ "assistant"