-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔨 Populate the guest cli args #393
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e6cd17d
Always populate the args for a guest with `["compute-app"]`
elliottt 3e8e42d
Add a test fixture for args
elliottt f75c5bb
Set the arguments for components as well
elliottt 28f61ed
Disable the component test for now
elliottt b39997b
Fix warning
elliottt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::common::{Test, TestResult}; | ||
use hyper::{body::to_bytes, StatusCode}; | ||
|
||
/// Run a program that tests its args. This checks that we're populating the argument list with the | ||
/// singleton "compute-app" value. | ||
/// Check that an empty response is sent downstream by default. | ||
/// | ||
/// `args.wasm` is a guest program checks its cli args. | ||
#[tokio::test(flavor = "multi_thread")] | ||
async fn empty_ok_response_by_default_after_args() -> TestResult { | ||
let resp = Test::using_fixture("args.wasm").against_empty().await?; | ||
|
||
assert_eq!(resp.status(), StatusCode::OK); | ||
assert!(to_bytes(resp.into_body()) | ||
.await | ||
.expect("can read body") | ||
.to_vec() | ||
.is_empty()); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Run a program that tests its args. This checks that we're populating the argument list with the | ||
/// singleton "compute-app" value. | ||
/// Check that an empty response is sent downstream by default. | ||
/// | ||
/// `args.wasm` is a guest program checks its cli args. | ||
#[tokio::test(flavor = "multi_thread")] | ||
// TODO: The adapter needs to plumb through support for argument handling. This was removed | ||
// explicitly when we thought we would target the proxy world only, but we'll need it back to | ||
// simplify adapting programs from languages that need a non-empty args list. | ||
#[should_panic] | ||
async fn empty_ok_response_by_default_after_args_component() { | ||
let resp = Test::using_fixture("args.wasm") | ||
.adapt_component() | ||
.against_empty() | ||
.await | ||
.unwrap(); | ||
|
||
assert_eq!(resp.status(), StatusCode::OK); | ||
assert!(to_bytes(resp.into_body()) | ||
.await | ||
.expect("can read body") | ||
.to_vec() | ||
.is_empty()); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod args; | ||
mod async_io; | ||
mod body; | ||
mod client_certs; | ||
|
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 |
---|---|---|
|
@@ -1088,6 +1088,7 @@ world compute { | |
import wasi:io/[email protected]; | ||
import wasi:io/[email protected]; | ||
import wasi:random/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
|
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,6 @@ | ||
fn main() { | ||
let args = Vec::from_iter(std::env::args()); | ||
|
||
assert_eq!(args.len(), 1); | ||
assert_eq!(args[0], "compute-app"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also want to add this for the
ComponentCtx::create_store
case as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this for components and enabled testing for it, but the adapter will need some changes to get the test passing. I'll put that on my TODO list for component parity, but don't think the adapter changes should block this PR.