Skip to content

Commit

Permalink
fix: add target wasm32-unknown-unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-herlemont committed Apr 4, 2024
1 parent a856352 commit aa9dcad
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_test_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
override: true
- name: Add target
run: rustup target add wasm32-unknown-unknown
- uses: extractions/setup-just@v1
- uses: hustcer/[email protected]
with:
Expand Down
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,26 @@ tokio = { version = "1", features = ["sync"], optional = true }
# TODO: channels with futures
# TODO: channels crossbeam

[dev-dependencies]
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
assert_fs = "1.1"
serial_test = { version = "3.0", features = ["file_locks"] }
shortcut_assert_fs = { version = "0.1.0" }
serial_test = { version = "3.0", features = ["file_locks"] }
criterion = { version = "0.5.1" }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.0"

[dev-dependencies]
skeptic = "0.13"
tokio = { version = "1.37", features = ["test-util","macros"] }
bincode = { version = "2.0.0-rc.3", features = ["serde"] }
criterion = { version = "0.5.1" }
doc-comment = "0.3.3"
uuid = { version = "1", features = ["serde", "v4"] }
uuid = { version = "1", features = ["serde", "v4", "js"] }
chrono = { version = "0.4", features = ["serde"] }
rand = "0.8"
once_cell = "1.19"


[features]
default = []

Expand Down
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ test_all *args:
just test_default {{args}};
just test_with_optional {{args}}

test_wasm:
cargo test --target wasm32-unknown-unknown

# List all available devices
test_mobile_all_devices:
Expand Down
2 changes: 2 additions & 0 deletions tests/convert_all.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]

use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
Expand Down
1 change: 1 addition & 0 deletions tests/util.rs → tests/create.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
use native_db::*;
use shortcut_assert_fs::TmpFs;

Expand Down
1 change: 1 addition & 0 deletions tests/modules.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod custom_type;
mod macro_def;
mod migrate;
Expand Down
1 change: 1 addition & 0 deletions tests/native_model.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
use bincode;
use bincode::{config, Decode, Encode};
use native_db::*;
Expand Down
1 change: 1 addition & 0 deletions tests/scan.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
// TODO: refactor and move to query/ folder

use native_db::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/simple_multithreads.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]

use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]

use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 2 additions & 0 deletions tests/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]

use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
Expand Down
12 changes: 12 additions & 0 deletions tests/wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;

#[wasm_bindgen_test]
fn pass() {
assert_eq!(1, 1);
}

#[wasm_bindgen_test]
fn fail() {
assert_eq!(1, 2);
}
1 change: 1 addition & 0 deletions tests/watch_tokio.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
#![cfg(feature = "tokio")]

use native_db::watch::Event;
Expand Down

0 comments on commit aa9dcad

Please sign in to comment.