Skip to content

Commit 8c06375

Browse files
committed
fix(ci): fix Windows test failures - gitattributes LF for prompts, bash tests cross-platform
1 parent 8d3627f commit 8c06375

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Force LF line endings for prompt files to ensure cross-platform string matching
2+
prompts/*.md text eol=lf

core/src/tools/builtin/bash.rs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ mod tests {
224224
#[tokio::test]
225225
async fn test_bash_echo() {
226226
let tool = BashTool;
227-
let ctx = ToolContext::new(PathBuf::from("/tmp"));
227+
let temp = tempfile::tempdir().unwrap();
228+
let ctx = ToolContext::new(temp.path().to_path_buf());
228229

229230
let result = tool
230231
.execute(&serde_json::json!({"command": "echo hello"}), &ctx)
@@ -236,9 +237,11 @@ mod tests {
236237
}
237238

238239
#[tokio::test]
240+
#[cfg(not(windows))]
239241
async fn test_bash_exit_code() {
240242
let tool = BashTool;
241-
let ctx = ToolContext::new(PathBuf::from("/tmp"));
243+
let temp = tempfile::tempdir().unwrap();
244+
let ctx = ToolContext::new(temp.path().to_path_buf());
242245

243246
let result = tool
244247
.execute(&serde_json::json!({"command": "exit 1"}), &ctx)
@@ -254,17 +257,40 @@ mod tests {
254257
);
255258
}
256259

260+
#[tokio::test]
261+
#[cfg(windows)]
262+
async fn test_bash_exit_code() {
263+
let tool = BashTool;
264+
let temp = tempfile::tempdir().unwrap();
265+
let ctx = ToolContext::new(temp.path().to_path_buf());
266+
267+
let result = tool
268+
.execute(&serde_json::json!({"command": "exit /b 1"}), &ctx)
269+
.await
270+
.unwrap();
271+
272+
assert!(!result.success);
273+
assert_eq!(
274+
result.metadata.as_ref().unwrap()["exit_code"]
275+
.as_i64()
276+
.unwrap(),
277+
1
278+
);
279+
}
280+
257281
#[tokio::test]
258282
async fn test_bash_missing_command() {
259283
let tool = BashTool;
260-
let ctx = ToolContext::new(PathBuf::from("/tmp"));
284+
let temp = tempfile::tempdir().unwrap();
285+
let ctx = ToolContext::new(temp.path().to_path_buf());
261286

262287
let result = tool.execute(&serde_json::json!({}), &ctx).await.unwrap();
263288
assert!(!result.success);
264289
assert!(result.content.contains("command"));
265290
}
266291

267292
#[tokio::test]
293+
#[cfg(not(windows))]
268294
async fn test_bash_workspace_dir() {
269295
let temp = tempfile::tempdir().unwrap();
270296
let tool = BashTool;
@@ -276,10 +302,30 @@ mod tests {
276302
.unwrap();
277303

278304
assert!(result.success);
279-
// The output should contain the temp dir path
280305
let canonical = temp.path().canonicalize().unwrap();
281306
assert!(result
282307
.content
283308
.contains(&canonical.to_string_lossy().to_string()));
284309
}
310+
311+
#[tokio::test]
312+
#[cfg(windows)]
313+
async fn test_bash_workspace_dir() {
314+
let temp = tempfile::tempdir().unwrap();
315+
let tool = BashTool;
316+
let ctx = ToolContext::new(temp.path().to_path_buf());
317+
318+
let result = tool
319+
.execute(&serde_json::json!({"command": "cd"}), &ctx)
320+
.await
321+
.unwrap();
322+
323+
assert!(result.success);
324+
let canonical = temp.path().canonicalize().unwrap();
325+
// Windows cd output uses backslashes; compare case-insensitively
326+
assert!(result
327+
.content
328+
.to_lowercase()
329+
.contains(&canonical.to_string_lossy().to_lowercase()));
330+
}
285331
}

0 commit comments

Comments
 (0)