Skip to content

Commit

Permalink
Support cli args in the adapter (fastly#394)
Browse files Browse the repository at this point in the history
Integrate the adapter allocator changes from bytecodealliance/wasmtime#8594,
which simplifies supporting cli args.

Additionally, enable the cli args test for components, as it's now passing.
  • Loading branch information
elliottt authored and GeeWee committed Jul 25, 2024
1 parent c93d8fb commit 8ac8f00
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 133 deletions.
4 changes: 0 additions & 4 deletions cli/tests/integration/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ async fn empty_ok_response_by_default_after_args() -> TestResult {
///
/// `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(true)
Expand Down
4 changes: 2 additions & 2 deletions crates/adapter/src/descriptors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::bindings::wasi::cli::{stderr, stdin, stdout};
use crate::bindings::wasi::io::streams::{InputStream, OutputStream};
use crate::{BumpArena, ImportAlloc, TrappingUnwrap};
use crate::{State, TrappingUnwrap};
use core::cell::{Cell, OnceCell, UnsafeCell};
use core::mem::MaybeUninit;
use wasi::{Errno, Fd};
Expand Down Expand Up @@ -78,7 +78,7 @@ pub struct Descriptors {
}

impl Descriptors {
pub fn new(_import_alloc: &ImportAlloc, _arena: &BumpArena) -> Self {
pub fn new(_state: &State) -> Self {
let d = Descriptors {
table: UnsafeCell::new(MaybeUninit::uninit()),
table_len: Cell::new(0),
Expand Down
2 changes: 1 addition & 1 deletion crates/adapter/src/fastly/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
macro_rules! with_buffer {
($buf:expr, $len:expr, $alloc:block, |$res:ident| $free:block) => {
crate::State::with::<FastlyStatus>(|state| {
let $res = state.import_alloc.with_buffer($buf, $len, || $alloc);
let $res = state.with_one_import_alloc($buf, $len, || $alloc);
$free;
Ok(())
})
Expand Down
Loading

0 comments on commit 8ac8f00

Please sign in to comment.