Skip to content

Commit

Permalink
Merge pull request #387 from bytecodealliance/jb/revamp-fixtures
Browse files Browse the repository at this point in the history
Revamp Rust project fixtures
  • Loading branch information
jbourassa authored Oct 16, 2024
2 parents fce3ec4 + 104514b commit 2626dd4
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 95 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[workspace]
resolver = "2"
members = ["ext"]
exclude = ["examples/rust-crate"]
exclude = [
"examples/rust-crate",
"spec/fixtures/wasi-debug",
"spec/fixtures/wasi-deterministic",
]

[profile.release]
codegen-units = 1 # more llvm optimizations
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore lockfile for fixtures to avoid irrelevant GitHub security alerts
Cargo.lock
Binary file removed spec/fixtures/deterministic.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions spec/fixtures/wasi-debug/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-wasip1"
File renamed without changes.
11 changes: 11 additions & 0 deletions spec/fixtures/wasi-debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Example WASI program used to test the WASI integration.

To update:

```shell
cargo build --release && \
wasm-opt -O \
--enable-bulk-memory \
target/wasm32-wasip1/release/wasi-debug.wasm \
-o ../wasi-debug.wasm
```
File renamed without changes.
Binary file added spec/fixtures/wasi-deterministic.wasm
Binary file not shown.
2 changes: 2 additions & 0 deletions spec/fixtures/wasi-deterministic/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-wasip1"
17 changes: 17 additions & 0 deletions spec/fixtures/wasi-deterministic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "wasi-deterministic"
version = "0.1.0"
edition = "2021"

[profile.release]
codegen-units = 1
opt-level = "s"
debug = false
strip = true
lto = true

[dependencies]
chrono = "0.4.38"
rand = "0.8.5"
serde = "1.0.210"
serde_json = "1.0.128"
12 changes: 12 additions & 0 deletions spec/fixtures/wasi-deterministic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Example WASI program used to test the WASI deterministic context integration.

To update:

```shell
cargo build --release && \
wasm-opt -O \
--enable-bulk-memory \
target/wasm32-wasip1/release/wasi-deterministic.wasm \
-o ../wasi-deterministic.wasm
```

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
// In a determinisitc build, the output of this program should be the same
// for every execution.
//
Expand All @@ -16,19 +15,14 @@
// - Elapsed time: system_time1_elapsed
//
// stderr: "Error: This is an error message"
//
// Contributing Notes:
// Compile: `cargo build --target wasm32-wasi`
// Run: `wasmtime run target/wasm32-wasi/debug/deterministic.wasm`
//

// Import rust's io and filesystem module
use chrono::{DateTime, Utc};
use rand::Rng;
use serde_json;
use std::collections::HashMap;
use std::thread::sleep;
use std::time::{Duration, SystemTime};
use chrono::{Utc, DateTime};

// Entry point to our WASI applications
fn main() {
Expand Down Expand Up @@ -62,7 +56,10 @@ fn main() {
Ok(elapsed) => {
// it prints '2'
println!("{}", elapsed.as_secs());
dict.insert("system_time1_elapsed".to_string(), elapsed.as_secs().to_string());
dict.insert(
"system_time1_elapsed".to_string(),
elapsed.as_secs().to_string(),
);
}
Err(e) => {
// an error occurred!
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/wasi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Wasmtime

# Compile module only once for speed
@compiled_wasi_module = @engine.precompile_module(IO.binread("spec/fixtures/wasi-debug.wasm"))
@compiled_wasi_deterministic_module = @engine.precompile_module(IO.binread("spec/fixtures/deterministic.wasm"))
@compiled_wasi_deterministic_module = @engine.precompile_module(IO.binread("spec/fixtures/wasi-deterministic.wasm"))
end

describe "Linker.new" do
Expand Down
79 changes: 0 additions & 79 deletions spec/wasi-debug/Cargo.lock

This file was deleted.

6 changes: 0 additions & 6 deletions spec/wasi-debug/src/README.md

This file was deleted.

0 comments on commit 2626dd4

Please sign in to comment.