Skip to content

Commit 54276e9

Browse files
committed
test(pluginlab): update tests for ls and cat plugins
1 parent aab52ed commit 54276e9

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

crates/pluginlab/.gitkeep

Whitespace-only changes.

crates/pluginlab/tests/e2e_test.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ mod e2e_test {
214214
std::env::set_current_dir(&project_root).unwrap();
215215
let mut session = spawn(
216216
&format!(
217-
"{} --dir crates/pluginlab/wit",
217+
"{} --dir crates/pluginlab",
218218
&build_command(&["plugin_ls.wasm"], "repl_logic_guest.wasm")
219219
),
220220
Some(TEST_TIMEOUT),
@@ -232,8 +232,57 @@ mod e2e_test {
232232
.expect("Didn't see REPL prompt");
233233
session.send_line("ls").expect("Failed to send command");
234234
session
235-
.exp_string("host-api.wit\r\nplugin-api.wit\r\nshared.wit\r\n")
235+
.exp_string(
236+
"D\tsrc\r\nD\ttests\r\nD\twit\r\nF\tCargo.toml\r\nF\tREADME.md\r\nF\tbuild.rs\r\n",
237+
)
236238
.expect("Didn't get listing of current directory");
239+
session.send_line("ls wit").expect("Failed to send command");
240+
session
241+
.exp_string("F\twit/host-api.wit\r\nF\twit/plugin-api.wit\r\nF\twit/shared.wit\r\n")
242+
.expect("Didn't get listing of wit directory");
243+
session
244+
.send_line("ls wit/host-api.wit")
245+
.expect("Failed to send command");
246+
session
247+
.exp_string("F\twit/host-api.wit\r\n")
248+
.expect("Didn't get listing of host-api.wit");
249+
}
250+
251+
#[test]
252+
fn test_cat_plugin() {
253+
let project_root = find_project_root();
254+
println!("Setting current directory to: {:?}", project_root);
255+
std::env::set_current_dir(&project_root).unwrap();
256+
let mut session = spawn(
257+
&format!(
258+
"{} --dir crates/pluginlab",
259+
&build_command(&["plugin_cat.wasm"], "repl_logic_guest.wasm")
260+
),
261+
Some(TEST_TIMEOUT),
262+
)
263+
.expect("Can't launch pluginlab with plugin greet");
264+
265+
session
266+
.exp_string("[Host] Starting REPL host...")
267+
.expect("Didn't see startup message");
268+
session
269+
.exp_string("[Host] Loading plugin:")
270+
.expect("Didn't see plugin loading message");
271+
session
272+
.exp_string("repl(0)>")
273+
.expect("Didn't see REPL prompt");
274+
session
275+
.send_line("cat wit")
276+
.expect("Failed to send command");
277+
session
278+
.exp_string("cat: wit: Is a directory")
279+
.expect("Didn't get expected error output for trying to cat a directory");
280+
session
281+
.send_line("cat wit/host-api.wit")
282+
.expect("Failed to send command");
283+
session
284+
.exp_string("package repl:api;")
285+
.expect("Didn't get expected contents of host-api.wit");
237286
}
238287

239288
#[test]

0 commit comments

Comments
 (0)