Skip to content
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

migrate versions test to new test framework #1242

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/test-rust-wasm/src/bin/versions.rs

This file was deleted.

11 changes: 7 additions & 4 deletions crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,12 @@ impl Runner<'_> {
dir: &Path,
) -> Result<(config::WitConfig, Vec<Component>)> {
let mut resolve = wit_parser::Resolve::default();
let pkg = resolve
.push_file(&wit)
.context("failed to load `test.wit` in test directory")?;

let wit_path = if dir.join("deps").exists() { dir } else { wit };
let (pkg, _files) = resolve.push_path(wit_path).context(format!(
"failed to load `test.wit` in test directory: {:?}",
&wit
))?;
let resolve = Arc::new(resolve);

let wit_contents = std::fs::read_to_string(wit)?;
Expand Down Expand Up @@ -378,7 +381,7 @@ impl Runner<'_> {
args: Vec::new(),
wit_config: wit_config.clone(),
world: resolve.worlds[*world].name.clone(),
wit_path: wit.to_path_buf(),
wit_path: wit_path.to_path_buf(),
};
let component = self
.parse_component(&path, *kind, bindgen)
Expand Down
17 changes: 17 additions & 0 deletions tests/runtime-new/versions/runner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using v1 = RunnerWorld.wit.imports.test.dep.v0_1_0;
using v2 = RunnerWorld.wit.imports.test.dep.v0_2_0;
using System.Text;

public class Program
{
public static void Main(string[] args){
Debug.Assert(v1.TestInterop.X() == 1.0f);
Debug.Assert(v1.TestInterop.Y(1.0f) == 2.0f);

Debug.Assert(v2.TestInterop.X() == 2.0f);
Debug.Assert(v2.TestInterop.Z(1.0f, 1.0f) == 4.0f);
}
}
11 changes: 11 additions & 0 deletions tests/runtime-new/versions/runner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include!(env!("BINDINGS"));

fn main() {
use test::dep0_1_0::test as v1;
assert_eq!(v1::x(), 1.0);
assert_eq!(v1::y(1.0), 2.0);

use test::dep0_2_0::test as v2;
assert_eq!(v2::x(), 2.0);
assert_eq!(v2::z(1.0, 1.0), 4.0);
}
28 changes: 28 additions & 0 deletions tests/runtime-new/versions/test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics;

namespace TestWorld.wit.exports.test.dep.v0_1_0 {
public class TestImpl : TestWorld.wit.exports.test.dep.v0_1_0.ITest
{
public static float X() {
return 1.0f;
}

public static float Y(float a){
return a + 1.0f;
}
}
}

namespace TestWorld.wit.exports.test.dep.v0_2_0
{
public class TestImpl : TestWorld.wit.exports.test.dep.v0_2_0.ITest
{
public static float X() {
return 2.0f;
}

public static float Z(float a, float b){
return a + b + 2.0f;
}
}
}
28 changes: 28 additions & 0 deletions tests/runtime-new/versions/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include!(env!("BINDINGS"));

use exports::test::dep0_1_0::test::Guest as v1;
use exports::test::dep0_2_0::test::Guest as v2;

struct Component;

export!(Component);

impl v1 for Component {
fn x() -> f32 {
1.0
}

fn y(a: f32) -> f32 {
1.0 + a
}
}

impl v2 for Component {
fn x() -> f32 {
2.0
}

fn z(a: f32, b: f32) -> f32 {
2.0 + a + b
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package test:versions;

world foo {
world runner {
import test:dep/test@0.1.0;
import test:dep/test@0.2.0;
}

world test {
export test:dep/test@0.1.0;
export test:dep/test@0.2.0;
export test-imports: func();
}
1 change: 0 additions & 1 deletion tests/runtime/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mod resource_into_inner;
mod resource_with_lists;
mod resources;
mod results;
mod versions;

struct MyCtx {}

Expand Down
56 changes: 0 additions & 56 deletions tests/runtime/versions.rs

This file was deleted.

47 changes: 0 additions & 47 deletions tests/runtime/versions/wasm.cs

This file was deleted.

46 changes: 0 additions & 46 deletions tests/runtime/versions/wasm.rs

This file was deleted.