Skip to content

Commit

Permalink
Merge #3344
Browse files Browse the repository at this point in the history
3344: Revert #3145 r=fschutt a=syrusakbary

This reverts buggy commit e1e08f4 merging #3145 

Co-authored-by: Syrus Akbary <[email protected]>
Co-authored-by: Felix Schütt <[email protected]>
Co-authored-by: Felix Schütt <[email protected]>
  • Loading branch information
4 people authored Nov 23, 2022
2 parents 4a903f8 + 36e39b3 commit f247db8
Show file tree
Hide file tree
Showing 19 changed files with 232 additions and 1,360 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/test-sys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,13 @@ jobs:
if: matrix.run_test && matrix.os != 'windows-2019'
shell: bash
run: |
make && make build-wasmer && make build-capi && make package-capi && make package
export WASMER_DIR=`pwd`/package
make test-integration-cli
make build-wasmer && make build-capi && make package-capi && make package && export WASMER_DIR=`pwd`/package && make test-integration-cli
env:
TARGET: ${{ matrix.target }}
TARGET_DIR: target/${{ matrix.target }}/release
CARGO_TARGET: --target ${{ matrix.target }}
WAPM_DEV_TOKEN: ${{ secrets.WAPM_DEV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

#- name: Test integration CLI
# if: matrix.run_test && matrix.os == 'windows-2019'
# shell: bash
Expand Down
10 changes: 0 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C

## **Unreleased**


## Added


## Changed


## Fixed


## 3.0.0 - 20/11/2022

## Added
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ test-capi-crate-%:
--no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) -- --nocapture

test-capi-integration-%:
# note: you need to do make build-capi and make package-capi first!
# Test the Wasmer C API tests for C
cd lib/c-api/tests; WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-integration-//) WASMER_DIR=`pwd`/../../../package make test
# Test the Wasmer C API examples
Expand Down
6 changes: 3 additions & 3 deletions examples/wasi_pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use std::io::{Read, Write};
use wasmer::{Instance, Module, Store};
use wasmer_compiler_cranelift::Cranelift;
use wasmer_wasi::{WasiBidirectionalSharedPipePair, WasiState};
use wasmer_wasi::{Pipe, WasiState};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let wasm_path = concat!(
Expand All @@ -36,8 +36,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

println!("Creating `WasiEnv`...");
// First, we create the `WasiEnv` with the stdio pipes
let mut input = WasiBidirectionalSharedPipePair::new().with_blocking(false);
let mut output = WasiBidirectionalSharedPipePair::new().with_blocking(false);
let mut input = Pipe::new();
let mut output = Pipe::new();
let wasi_env = WasiState::new("hello")
.stdin(Box::new(input.clone()))
.stdout(Box::new(output.clone()))
Expand Down
46 changes: 26 additions & 20 deletions lib/api/tests/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,28 @@ fn memory_grow() -> Result<(), String> {
fn function_new() -> Result<(), String> {
let mut store = Store::default();
let function = Function::new_typed(&mut store, || {});
assert_eq!(function.ty(&mut store), FunctionType::new(vec![], vec![]));
assert_eq!(
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![])
);
let function = Function::new_typed(&mut store, |_a: i32| {});
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![Type::I32], vec![])
);
let function = Function::new_typed(&mut store, |_a: i32, _b: i64, _c: f32, _d: f64| {});
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![])
);
let function = Function::new_typed(&mut store, || -> i32 { 1 });
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![Type::I32])
);
let function = Function::new_typed(&mut store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) });
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64])
);
Ok(())
Expand All @@ -243,11 +246,14 @@ fn function_new_env() -> Result<(), String> {
let my_env = MyEnv {};
let env = FunctionEnv::new(&mut store, my_env);
let function = Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>| {});
assert_eq!(function.ty(&mut store), FunctionType::new(vec![], vec![]));
assert_eq!(
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![])
);
let function =
Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>, _a: i32| {});
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![Type::I32], vec![])
);
let function = Function::new_typed_with_env(
Expand All @@ -256,13 +262,13 @@ fn function_new_env() -> Result<(), String> {
|_env: FunctionEnvMut<MyEnv>, _a: i32, _b: i64, _c: f32, _d: f64| {},
);
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![])
);
let function =
Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>| -> i32 { 1 });
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![Type::I32])
);
let function = Function::new_typed_with_env(
Expand All @@ -271,7 +277,7 @@ fn function_new_env() -> Result<(), String> {
|_env: FunctionEnvMut<MyEnv>| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) },
);
assert_eq!(
function.ty(&mut store),
function.ty(&mut store).clone(),
FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64])
);
Ok(())
Expand All @@ -288,35 +294,35 @@ fn function_new_dynamic() -> Result<(), String> {
&function_type,
|_values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32], vec![]);
let function = Function::new(
&mut store,
&function_type,
|_values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
let function = Function::new(
&mut store,
&function_type,
|_values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32]);
let function = Function::new(
&mut store,
&function_type,
|_values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]);
let function = Function::new(
&mut store,
&function_type,
|_values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);

// Using array signature
let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]);
Expand Down Expand Up @@ -350,39 +356,39 @@ fn function_new_dynamic_env() -> Result<(), String> {
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32], vec![]);
let function = Function::new_with_env(
&mut store,
&env,
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
let function = Function::new_with_env(
&mut store,
&env,
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32]);
let function = Function::new_with_env(
&mut store,
&env,
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]);
let function = Function::new_with_env(
&mut store,
&env,
&function_type,
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
);
assert_eq!(function.ty(&mut store), function_type);
assert_eq!(function.ty(&mut store).clone(), function_type);

// Using array signature
let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]);
Expand Down
10 changes: 5 additions & 5 deletions lib/api/tests/reference_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub mod reference_types {
let global: &Global = instance.exports.get_global("global")?;
{
let er = ExternRef::new(&mut store, 3usize);
global.set(&mut store, Value::ExternRef(Some(er)))?;
global.set(&mut store, Value::ExternRef(Some(er.clone())))?;
}
let get_from_global: TypedFunction<(), Option<ExternRef>> = instance
.exports
Expand Down Expand Up @@ -398,7 +398,7 @@ pub mod reference_types {

let er = ExternRef::new(&mut store, 3usize);

let result = pass_extern_ref.call(&mut store, Some(er));
let result = pass_extern_ref.call(&mut store, Some(er.clone()));
assert!(result.is_err());

Ok(())
Expand Down Expand Up @@ -442,7 +442,7 @@ pub mod reference_types {
let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 10_000)?;
assert_eq!(result, -1);

let result = grow_table_with_ref.call(&mut store, Some(er1), 8)?;
let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 8)?;
assert_eq!(result, 2);

for i in 2..10 {
Expand All @@ -454,15 +454,15 @@ pub mod reference_types {
}

{
fill_table_with_ref.call(&mut store, Some(er2), 0, 2)?;
fill_table_with_ref.call(&mut store, Some(er2.clone()), 0, 2)?;
}

{
table2.set(&mut store, 0, Value::ExternRef(Some(er3.clone())))?;
table2.set(&mut store, 1, Value::ExternRef(Some(er3.clone())))?;
table2.set(&mut store, 2, Value::ExternRef(Some(er3.clone())))?;
table2.set(&mut store, 3, Value::ExternRef(Some(er3.clone())))?;
table2.set(&mut store, 4, Value::ExternRef(Some(er3)))?;
table2.set(&mut store, 4, Value::ExternRef(Some(er3.clone())))?;
}

{
Expand Down
Loading

0 comments on commit f247db8

Please sign in to comment.