Skip to content

Commit a0426d5

Browse files
committed
feat(web-host): add echogo plugin with e2e test
1 parent c7fdfaa commit a0426d5

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

packages/web-host/src/hooks/exampleCommands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ const commands = [
5555
"man weather",
5656
"help",
5757
"echoc This is the same as `echo`, implemented in C",
58-
"echoc try `man echo` vs `man echoc`",
58+
"echogo Same, but in Go",
59+
"echoc Whole C toolchain available",
60+
"echogo Whole Go toolchain available",
61+
"echo try `man echo` vs `man echoc` vs `man echogo`",
5962
"echoc qux",
63+
"echogo qux",
6064
];
6165

6266
export function useGetExampleCommand() {

packages/web-host/src/utils/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const pluginSourceUrlMapping = {
88
cat: "https://github.com/topheman/webassembly-component-model-experiments/tree/master/crates/plugin-cat",
99
echoc:
1010
"https://github.com/topheman/webassembly-component-model-experiments/blob/master/c_modules/plugin-echo/component.c",
11+
echogo:
12+
"https://github.com/topheman/webassembly-component-model-experiments/blob/master/go_modules/plugin-echo/main.go",
1113
tee: "https://github.com/topheman/webassembly-component-model-experiments/tree/master/crates/plugin-tee",
1214
} as const;
1315

packages/web-host/src/wasm/engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async function loadPlugins({
4343
import("./generated/plugin_cat/transpiled/plugin_cat.js"),
4444
import("./generated/plugin_tee/transpiled/plugin_tee.js"),
4545
import("./generated/plugin-echo-c/transpiled/plugin-echo-c.js"),
46+
import("./generated/plugin-echo-go/transpiled/plugin-echo-go.js"),
4647
]).then((plugins) =>
4748
plugins.map((plugin) => {
4849
// Since we `allowHtml`, which will `dangerouslySetInnerHTML`, we need to sanitize the plugin name

packages/web-host/tests/repl-logic.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ test("list-commands", async ({ page }) => {
7474
`cat plugin
7575
echo plugin
7676
echoc plugin
77+
echogo plugin
7778
export reserved
7879
greet plugin
7980
help reserved

packages/web-host/tests/repl-plugins.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ test("echoc foo", async ({ page }) => {
1111
await fillAndSubmitCommand(page, "echoc foo", { expectStdout: "foo" });
1212
});
1313

14+
test("echogo foo", async ({ page }) => {
15+
await page.goto("/#repl");
16+
await fillAndSubmitCommand(page, "echogo foo", { expectStdout: "foo" });
17+
});
18+
1419
test("greet World", async ({ page }) => {
1520
await page.goto("/#repl");
1621
await fillAndSubmitCommand(page, "greet World", {

scripts/prepare-wasm-files.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ prepare_wasm_files() {
4242
"target/wasm32-wasip1/$mode/plugin_weather.wasm"
4343
"target/wasm32-wasip1/$mode/plugin_tee.wasm"
4444
"c_modules/plugin-echo/plugin-echo-c.wasm"
45+
"go_modules/plugin-echo/plugin-echo-go.wasm"
4546
"target/wasm32-wasip1/$mode/repl_logic_guest.wasm"
4647
)
4748

0 commit comments

Comments
 (0)