Use tempfile tempdir instead of hardcoding /private/tmp
This commit is contained in:
parent
f1af9d5fbd
commit
2ecb5b2ff6
2 changed files with 23 additions and 10 deletions
|
@ -893,9 +893,10 @@ pub(crate) mod tests {
|
||||||
#[cfg_attr(not(feature = "e2e"), ignore)]
|
#[cfg_attr(not(feature = "e2e"), ignore)]
|
||||||
async fn test_todo_plan(cx: &mut TestAppContext) {
|
async fn test_todo_plan(cx: &mut TestAppContext) {
|
||||||
let fs = e2e_tests::init_test(cx).await;
|
let fs = e2e_tests::init_test(cx).await;
|
||||||
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let thread =
|
let thread =
|
||||||
e2e_tests::new_test_thread(ClaudeCode, project.clone(), "/private/tmp", cx).await;
|
e2e_tests::new_test_thread(ClaudeCode, project.clone(), tempdir.path(), cx).await;
|
||||||
|
|
||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
|
@ -949,6 +950,8 @@ pub(crate) mod tests {
|
||||||
));
|
));
|
||||||
assert_eq!(thread.plan().entries.len(), entries_len);
|
assert_eq!(thread.plan().entries.len(), entries_len);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
drop(tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -13,12 +13,12 @@ use gpui::{Entity, TestAppContext};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use project::{FakeFs, Project};
|
use project::{FakeFs, Project};
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use util::path;
|
|
||||||
|
|
||||||
pub async fn test_basic(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
pub async fn test_basic(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
||||||
let fs = init_test(cx).await;
|
let fs = init_test(cx).await;
|
||||||
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let thread = new_test_thread(server, project.clone(), "/private/tmp", cx).await;
|
let thread = new_test_thread(server, project.clone(), tempdir.path(), cx).await;
|
||||||
|
|
||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| thread.send_raw("Hello from Zed!", cx))
|
.update(cx, |thread, cx| thread.send_raw("Hello from Zed!", cx))
|
||||||
|
@ -40,6 +40,8 @@ pub async fn test_basic(server: impl AgentServer + 'static, cx: &mut TestAppCont
|
||||||
AgentThreadEntry::AssistantMessage(_)
|
AgentThreadEntry::AssistantMessage(_)
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
drop(tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_path_mentions(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
pub async fn test_path_mentions(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
||||||
|
@ -118,7 +120,7 @@ pub async fn test_tool_call(server: impl AgentServer + 'static, cx: &mut TestApp
|
||||||
std::fs::write(&foo_path, "Lorem ipsum dolor").expect("failed to write file");
|
std::fs::write(&foo_path, "Lorem ipsum dolor").expect("failed to write file");
|
||||||
|
|
||||||
let project = Project::example([tempdir.path()], &mut cx.to_async()).await;
|
let project = Project::example([tempdir.path()], &mut cx.to_async()).await;
|
||||||
let thread = new_test_thread(server, project.clone(), "/private/tmp", cx).await;
|
let thread = new_test_thread(server, project.clone(), tempdir.path(), cx).await;
|
||||||
|
|
||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| {
|
.update(cx, |thread, cx| {
|
||||||
|
@ -156,8 +158,9 @@ pub async fn test_tool_call_with_permission(
|
||||||
cx: &mut TestAppContext,
|
cx: &mut TestAppContext,
|
||||||
) {
|
) {
|
||||||
let fs = init_test(cx).await;
|
let fs = init_test(cx).await;
|
||||||
let project = Project::test(fs, [path!("/private/tmp").as_ref()], cx).await;
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let thread = new_test_thread(server, project.clone(), "/private/tmp", cx).await;
|
let project = Project::test(fs, [tempdir.path()], cx).await;
|
||||||
|
let thread = new_test_thread(server, project.clone(), tempdir.path(), cx).await;
|
||||||
let full_turn = thread.update(cx, |thread, cx| {
|
let full_turn = thread.update(cx, |thread, cx| {
|
||||||
thread.send_raw(
|
thread.send_raw(
|
||||||
r#"Run exactly `touch hello.txt && echo "Hello, world!" | tee hello.txt` in the terminal."#,
|
r#"Run exactly `touch hello.txt && echo "Hello, world!" | tee hello.txt` in the terminal."#,
|
||||||
|
@ -239,13 +242,15 @@ pub async fn test_tool_call_with_permission(
|
||||||
"Expected content to contain 'Hello'"
|
"Expected content to contain 'Hello'"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
drop(tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_cancel(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
pub async fn test_cancel(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
||||||
let fs = init_test(cx).await;
|
let fs = init_test(cx).await;
|
||||||
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let project = Project::test(fs, [path!("/private/tmp").as_ref()], cx).await;
|
let project = Project::test(fs, [tempdir.path()], cx).await;
|
||||||
let thread = new_test_thread(server, project.clone(), "/private/tmp", cx).await;
|
let thread = new_test_thread(server, project.clone(), tempdir.path(), cx).await;
|
||||||
let _ = thread.update(cx, |thread, cx| {
|
let _ = thread.update(cx, |thread, cx| {
|
||||||
thread.send_raw(
|
thread.send_raw(
|
||||||
r#"Run exactly `touch hello.txt && echo "Hello, world!" | tee hello.txt` in the terminal."#,
|
r#"Run exactly `touch hello.txt && echo "Hello, world!" | tee hello.txt` in the terminal."#,
|
||||||
|
@ -308,12 +313,15 @@ pub async fn test_cancel(server: impl AgentServer + 'static, cx: &mut TestAppCon
|
||||||
AgentThreadEntry::AssistantMessage(..),
|
AgentThreadEntry::AssistantMessage(..),
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
drop(tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_thread_drop(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
pub async fn test_thread_drop(server: impl AgentServer + 'static, cx: &mut TestAppContext) {
|
||||||
let fs = init_test(cx).await;
|
let fs = init_test(cx).await;
|
||||||
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let project = Project::test(fs, [], cx).await;
|
let project = Project::test(fs, [], cx).await;
|
||||||
let thread = new_test_thread(server, project.clone(), "/private/tmp", cx).await;
|
let thread = new_test_thread(server, project.clone(), tempdir.path(), cx).await;
|
||||||
|
|
||||||
thread
|
thread
|
||||||
.update(cx, |thread, cx| thread.send_raw("Hello from test!", cx))
|
.update(cx, |thread, cx| thread.send_raw("Hello from test!", cx))
|
||||||
|
@ -329,6 +337,8 @@ pub async fn test_thread_drop(server: impl AgentServer + 'static, cx: &mut TestA
|
||||||
|
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
assert!(!weak_thread.is_upgradable());
|
assert!(!weak_thread.is_upgradable());
|
||||||
|
|
||||||
|
drop(tempdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue