Skip to content

Commit 8b5e608

Browse files
committed
feat(plugin-tee): prepare tests
1 parent bd98428 commit 8b5e608

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

crates/pluginlab/tests/e2e_rust_plugins.rs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,142 @@ mod e2e_rust_plugins {
173173
.exp_string("# Documents")
174174
.expect("Didn't get expected contents of README.md");
175175
}
176+
177+
#[test]
178+
fn test_tee_plugin_new_file() {
179+
let project_root = find_project_root();
180+
println!("Setting current directory to: {:?}", project_root);
181+
std::env::set_current_dir(&project_root).unwrap();
182+
let mut session = spawn(
183+
&format!(
184+
"{} --dir tmp/filesystem --allow-read",
185+
&build_command(
186+
&["plugin_tee.wasm", "plugin_echo.wasm", "plugin_cat.wasm"],
187+
"repl_logic_guest.wasm"
188+
)
189+
),
190+
Some(TEST_TIMEOUT),
191+
)
192+
.expect("Can't launch pluginlab with plugin greet");
193+
194+
session
195+
.exp_string("[Host] Starting REPL host...")
196+
.expect("Didn't see startup message");
197+
session
198+
.exp_string("[Host] Loading plugin:")
199+
.expect("Didn't see plugin loading message");
200+
session
201+
.exp_string("repl(0)>")
202+
.expect("Didn't see REPL prompt");
203+
session
204+
.send_line("echo hello")
205+
.expect("Failed to send command");
206+
session
207+
.exp_string("hello\r\nrepl(0)>")
208+
.expect("Didn't get expected output from echo plugin");
209+
session
210+
.send_line("tee hello.txt")
211+
.expect("Failed to send command");
212+
session
213+
.exp_string("hello\r\nrepl(0)>")
214+
.expect("Didn't get expected output from tee plugin");
215+
session
216+
.send_line("cat hello.txt")
217+
.expect("Failed to send command");
218+
session
219+
.exp_string("hello\r\nrepl(0)>")
220+
.expect("Didn't get expected contents of hello.txt");
221+
}
222+
223+
#[test]
224+
fn test_tee_plugin_replace_file() {
225+
let project_root = find_project_root();
226+
println!("Setting current directory to: {:?}", project_root);
227+
std::env::set_current_dir(&project_root).unwrap();
228+
let mut session = spawn(
229+
&format!(
230+
"{} --dir tmp/filesystem --allow-read",
231+
&build_command(
232+
&["plugin_tee.wasm", "plugin_echo.wasm", "plugin_cat.wasm"],
233+
"repl_logic_guest.wasm"
234+
)
235+
),
236+
Some(TEST_TIMEOUT),
237+
)
238+
.expect("Can't launch pluginlab with plugin greet");
239+
240+
session
241+
.exp_string("[Host] Starting REPL host...")
242+
.expect("Didn't see startup message");
243+
session
244+
.exp_string("[Host] Loading plugin:")
245+
.expect("Didn't see plugin loading message");
246+
session
247+
.exp_string("repl(0)>")
248+
.expect("Didn't see REPL prompt");
249+
session
250+
.send_line("echo hello")
251+
.expect("Failed to send command");
252+
session
253+
.exp_string("hello\r\nrepl(0)>")
254+
.expect("Didn't get expected output from echo plugin");
255+
session
256+
.send_line("tee documents/notes.txt")
257+
.expect("Failed to send command");
258+
session
259+
.exp_string("hello\r\nrepl(0)>")
260+
.expect("Didn't get expected output from tee plugin");
261+
session
262+
.send_line("cat documents/notes.txt")
263+
.expect("Failed to send command");
264+
session
265+
.exp_string("hello\r\nrepl(0)>")
266+
.expect("Didn't get expected contents of hello.txt");
267+
}
268+
269+
#[test]
270+
fn test_tee_plugin_append_file() {
271+
let project_root = find_project_root();
272+
println!("Setting current directory to: {:?}", project_root);
273+
std::env::set_current_dir(&project_root).unwrap();
274+
let mut session = spawn(
275+
&format!(
276+
"{} --dir tmp/filesystem --allow-read",
277+
&build_command(
278+
&["plugin_tee.wasm", "plugin_echo.wasm", "plugin_cat.wasm"],
279+
"repl_logic_guest.wasm"
280+
)
281+
),
282+
Some(TEST_TIMEOUT),
283+
)
284+
.expect("Can't launch pluginlab with plugin greet");
285+
286+
session
287+
.exp_string("[Host] Starting REPL host...")
288+
.expect("Didn't see startup message");
289+
session
290+
.exp_string("[Host] Loading plugin:")
291+
.expect("Didn't see plugin loading message");
292+
session
293+
.exp_string("repl(0)>")
294+
.expect("Didn't see REPL prompt");
295+
session
296+
.send_line("echo hello")
297+
.expect("Failed to send command");
298+
session
299+
.exp_string("hello\r\nrepl(0)>")
300+
.expect("Didn't get expected output from echo plugin");
301+
session
302+
.send_line("tee -a data/sample.csv")
303+
.expect("Failed to send command");
304+
session
305+
.exp_string("hello\r\nrepl(0)>")
306+
.expect("Didn't get expected output from tee plugin");
307+
session
308+
.send_line("cat data/sample.csv")
309+
.expect("Failed to send command");
310+
session
311+
.exp_string("id,name,age,city,active\r\n1,Alice,28,New York,true\r\n2,Bob,32,San Francisco,true\r\n3,Charlie,25,Chicago,false\r\n4,Diana,29,Boston,true\r\n5,Eve,35,Seattle,true\r\nhello\r\nrepl(0)>")
312+
.expect("Didn't get expected contents of sample.csv");
313+
}
176314
}

0 commit comments

Comments
 (0)