-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli)!: Allow specifying WASI environment variables and CLI args (#…
- Loading branch information
1 parent
5efb54c
commit fb8fbf2
Showing
7 changed files
with
114 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
open Grain_tests.TestFramework; | ||
open Grain_tests.Runner; | ||
|
||
describe("wasi args and env", ({test, testSkip}) => { | ||
let test_or_skip = | ||
Sys.backend_type == Other("js_of_ocaml") ? testSkip : test; | ||
|
||
let assertRun = makeRunner(test_or_skip); | ||
|
||
let print_wasi_info = {| | ||
include "sys/process" | ||
include "array" | ||
include "string" | ||
match (Process.argv()) { | ||
Ok(args) => print(Array.slice(1, args)), | ||
_ => print("Error reading args") | ||
} | ||
match (Process.env()) { | ||
Ok(env) => print(env), | ||
_ => print("Error reading env") | ||
} | ||
|}; | ||
|
||
assertRun( | ||
~extra_args=[|"--", "a", "b"|], | ||
"print_args1", | ||
print_wasi_info, | ||
"[> \"a\", \"b\"]\n[> ]\n", | ||
); | ||
assertRun( | ||
~extra_args=[|"a", "b"|], | ||
"print_args2", | ||
print_wasi_info, | ||
"[> ]\n[> ]\n", | ||
); | ||
assertRun( | ||
~extra_args=[|"--env=FOO=bar", "a", "b"|], | ||
"print_args3", | ||
print_wasi_info, | ||
"[> ]\n[> \"FOO=bar\"]\n", | ||
); | ||
assertRun( | ||
~extra_args=[|"--env", "FOO=bar", "BAR=baz", "BAZ"|], | ||
"print_args4", | ||
print_wasi_info, | ||
"[> ]\n[> \"FOO=bar\", \"BAR=baz\", \"BAZ=\"]\n", | ||
); | ||
assertRun( | ||
~extra_args=[|"--env", "FOO=bar", "--", "a", "b"|], | ||
"print_args5", | ||
print_wasi_info, | ||
"[> \"a\", \"b\"]\n[> \"FOO=bar\"]\n", | ||
); | ||
assertRun( | ||
~extra_args=[|"--", "a", "b", "--env", "FOO=bar"|], | ||
"print_args6", | ||
print_wasi_info, | ||
"[> \"a\", \"b\", \"--env\", \"FOO=bar\"]\n[> ]\n", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters