Skip to content

Commit 64aa94a

Browse files
committed
fix(doctest): use platform-specific temp paths in command module examples
The doctest for the command module was using hardcoded /tmp path which doesn't exist on Windows, causing the doctest to fail when running on Windows CI runners. Fixed by using cfg!(windows) to select appropriate temp directory path on each platform. Fixes Windows doctest failure: crates/mcp-core/src/command.rs - command (line 16) All 352 tests passing.
1 parent 977d2fe commit 64aa94a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/mcp-core/src/command.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@
1717
//! use mcp_core::validate_command;
1818
//!
1919
//! // Valid absolute path
20-
//! # std::fs::write("/tmp/test-mcp-server", "#!/bin/sh\n").unwrap();
20+
//! # let temp_file = if cfg!(windows) {
21+
//! # std::env::temp_dir().join("test-mcp-server.exe")
22+
//! # } else {
23+
//! # std::path::PathBuf::from("/tmp/test-mcp-server")
24+
//! # };
25+
//! # std::fs::write(&temp_file, "#!/bin/sh\n").unwrap();
2126
//! # #[cfg(unix)]
2227
//! # {
2328
//! # use std::os::unix::fs::PermissionsExt;
24-
//! # let mut perms = std::fs::metadata("/tmp/test-mcp-server").unwrap().permissions();
29+
//! # let mut perms = std::fs::metadata(&temp_file).unwrap().permissions();
2530
//! # perms.set_mode(0o755);
26-
//! # std::fs::set_permissions("/tmp/test-mcp-server", perms).unwrap();
31+
//! # std::fs::set_permissions(&temp_file, perms).unwrap();
2732
//! # }
28-
//! let result = validate_command("/tmp/test-mcp-server");
29-
//! # std::fs::remove_file("/tmp/test-mcp-server").ok();
33+
//! let result = validate_command(temp_file.to_str().unwrap());
34+
//! # std::fs::remove_file(&temp_file).ok();
3035
//! # if result.is_err() {
3136
//! # // On some systems, execution permission check might fail
3237
//! # return;

0 commit comments

Comments
 (0)