Skip to content

Commit

Permalink
move fixture test projects into subdir, maintain ci, update tools-ver…
Browse files Browse the repository at this point in the history
…sion (#662)

* move fixture test projects into subdir, maintain ci, update tools-version

* be less picky in matching error reason source file path
  • Loading branch information
tessi authored Nov 9, 2024
1 parent d707f8a commit 1d551aa
Show file tree
Hide file tree
Showing 34 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true }
- { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, use-cross: true }
- { target: aarch64-apple-darwin, os: macos-12 }
- { target: x86_64-apple-darwin, os: macos-12 }
- { target: aarch64-apple-darwin, os: macos-15 }
- { target: x86_64-apple-darwin, os: macos-15 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, use-cross: true }
- { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true, cargo-args: "--no-default-features"}
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ wasmex-*.tar

# Cargo things in the Rust part of this package
priv/native/libwasmex.so
test/wasm_source/target/*
test/wasm_link_test/target/*
test/wasm_link_dep_test/target/*
test/wasm_link_import_test/target/*
test/**/target/*

.mix_tasks
**/.DS_Store
Expand Down
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
erlang 27.0
elixir 1.17.0-otp-27
erlang 27.1.2
elixir 1.17.3-otp-27
rust 1.82.0
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.linkedProjects": [
"./native/wasmex/Cargo.toml"
]
}
2 changes: 1 addition & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
1. Commit the version bump and push it
1. Tag the commit with the new version number `git tag -a v0.8.0` - copy the changelog into the tag message
1. Push the tag `git push --tags`
1. Wait for the CI to create the github release and precompied binaries
1. Wait for the CI to create the github release and precompiled binaries
1. Edit the GitHub release with the `CHANGELOG.md` content
1. Download the precompiled binaries with `mix rustler_precompiled.download Wasmex.Native --all --ignore-unavailable --print`
1. Inspect the output and the checksum-Elixir.Wasmex.Native.exs file
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
defmodule TestHelper do
@wasm_test_source_dir "#{Path.dirname(__ENV__.file)}/wasm_test"
@wasm_link_test_source_dir "#{Path.dirname(__ENV__.file)}/wasm_link_test"
@wasm_link_dep_test_source_dir "#{Path.dirname(__ENV__.file)}/wasm_link_dep_test"
@wasm_link_import_test_source_dir "#{Path.dirname(__ENV__.file)}/wasm_link_import_test"
@wasm_import_test_source_dir "#{Path.dirname(__ENV__.file)}/wasm_import_test"
@wasi_test_source_dir "#{Path.dirname(__ENV__.file)}/wasi_test"
@fixture_project_dir "#{Path.dirname(__ENV__.file)}/fixture_projects"
@wasm_test_source_dir "#{@fixture_project_dir}/wasm_test"
@wasm_link_test_source_dir "#{@fixture_project_dir}/wasm_link_test"
@wasm_link_dep_test_source_dir "#{@fixture_project_dir}/wasm_link_dep_test"
@wasm_link_import_test_source_dir "#{@fixture_project_dir}/wasm_link_import_test"
@wasm_import_test_source_dir "#{@fixture_project_dir}/wasm_import_test"
@wasi_test_source_dir "#{@fixture_project_dir}/wasi_test"

def wasm_test_file_path,
do: "#{@wasm_test_source_dir}/target/wasm32-unknown-unknown/debug/wasmex_test.wasm"
Expand Down Expand Up @@ -40,7 +41,7 @@ defmodule TestHelper do
"--target=wasm32-unknown-unknown",
"--",
"--extern",
"utils=../wasm_test/target/wasm32-unknown-unknown/debug/wasmex_test.wasm"
"utils=#{@wasm_test_source_dir}/target/wasm32-unknown-unknown/debug/wasmex_test.wasm"
],
cd: @wasm_link_test_source_dir
)
Expand All @@ -53,7 +54,7 @@ defmodule TestHelper do
"--target=wasm32-unknown-unknown",
"--",
"--extern",
"calculator=../wasm_link_test/target/wasm32-unknown-unknown/debug/wasmex_link_test.wasm"
"calculator=#{@wasm_link_test_source_dir}/target/wasm32-unknown-unknown/debug/wasmex_link_test.wasm"
],
cd: @wasm_link_dep_test_source_dir
)
Expand Down
14 changes: 8 additions & 6 deletions test/wasi_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ defmodule WasiTest do
{:ok, stdout} = Wasmex.Pipe.new()

wasi = %WasiOptions{
args: ["wasmex", "list_files", "test/wasi_test/src"],
args: ["wasmex", "list_files", "test/fixture_projects/wasi_test/src"],
stdout: stdout,
preopen: [%PreopenOptions{path: "test/wasi_test/src"}]
preopen: [%PreopenOptions{path: "test/fixture_projects/wasi_test/src"}]
}

instance =
Expand All @@ -156,7 +156,7 @@ defmodule WasiTest do

{:ok, _} = Wasmex.call_function(instance, :_start, [])
Wasmex.Pipe.seek(stdout, 0)
assert Wasmex.Pipe.read(stdout) == "\"test/wasi_test/src/main.rs\"\n"
assert Wasmex.Pipe.read(stdout) == "\"test/fixture_projects/wasi_test/src/main.rs\"\n"
end

test "list files on a preopened dir with alias" do
Expand All @@ -165,7 +165,9 @@ defmodule WasiTest do
wasi = %WasiOptions{
args: ["wasmex", "list_files", "aliased_src"],
stdout: stdout,
preopen: [%PreopenOptions{path: "test/wasi_test/src", alias: "aliased_src"}]
preopen: [
%PreopenOptions{path: "test/fixture_projects/wasi_test/src", alias: "aliased_src"}
]
}

instance =
Expand All @@ -184,7 +186,7 @@ defmodule WasiTest do
wasi = %WasiOptions{
args: ["wasmex", "read_file", "src/main.rs"],
stdout: stdout,
preopen: [%PreopenOptions{path: "test/wasi_test/src", alias: "src"}]
preopen: [%PreopenOptions{path: "test/fixture_projects/wasi_test/src", alias: "src"}]
}

instance =
Expand All @@ -193,7 +195,7 @@ defmodule WasiTest do
)

{:ok, _} = Wasmex.call_function(instance, :_start, [])
{:ok, expected_content} = File.read("test/wasi_test/src/main.rs")
{:ok, expected_content} = File.read("test/fixture_projects/wasi_test/src/main.rs")
Wasmex.Pipe.seek(stdout, 0)
assert Wasmex.Pipe.read(stdout) == expected_content <> "\n"
end
Expand Down
2 changes: 1 addition & 1 deletion test/wasmex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ defmodule WasmexTest do
assert {:error, reason} = Wasmex.call_function(pid, :divide, [1, 0])

# contains source file and line number
assert reason =~ "wasmex/test/wasm_test/src/lib.rs:75:5"
assert reason =~ "wasm_test/src/lib.rs:75:5"
end
end

Expand Down

0 comments on commit 1d551aa

Please sign in to comment.