From 155b3cee4c499187c5a49551e1d50f59cb6e12fe Mon Sep 17 00:00:00 2001 From: MaulingMonkey Date: Sun, 1 Sep 2019 14:29:37 -0700 Subject: [PATCH] Fix wasm-pack test, disable test_forward/systex. --- Cargo.toml | 3 +++ examples/test_forward.rs | 9 ++++++++- examples/test_sysex.rs | 4 ++-- src/common.rs | 10 ++++++---- tests/virtual.rs | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c9430ba..05a27a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,3 +55,6 @@ web-sys = { version = "0.3", features = [ "MidiPort", "MidiPortType" ]} + +[target.'cfg(target_arch = "wasm32")'.dev-dependencies] +wasm-bindgen-test = "0.2" diff --git a/examples/test_forward.rs b/examples/test_forward.rs index 6831754..8c6c3a7 100644 --- a/examples/test_forward.rs +++ b/examples/test_forward.rs @@ -12,6 +12,7 @@ fn main() { } } +#[cfg(not(target_arch = "wasm32"))] // conn_out is not `Send` in Web MIDI, which means it cannot be passed to connect fn run() -> Result<(), Box> { let mut input = String::new(); @@ -61,4 +62,10 @@ fn run() -> Result<(), Box> { println!("Closing connections"); Ok(()) -} \ No newline at end of file +} + +#[cfg(target_arch = "wasm32")] +fn run() -> Result<(), Box> { + println!("test_forward cannot run on Web MIDI"); + Ok(()) +} diff --git a/examples/test_sysex.rs b/examples/test_sysex.rs index 61a2316..2bd74fb 100644 --- a/examples/test_sysex.rs +++ b/examples/test_sysex.rs @@ -7,7 +7,7 @@ fn main() { } } -#[cfg(not(windows))] // virtual ports are not supported on Windows +#[cfg(not(any(windows, target_arch = "wasm32")))] // virtual ports are not supported on Windows nor on Web MIDI mod example { use std::thread::sleep; @@ -73,7 +73,7 @@ pub fn run() -> Result<(), Box> { } // needed to compile successfully -#[cfg(windows)] mod example { +#[cfg(any(windows, target_arch = "wasm32"))] mod example { use std::error::Error; pub fn run() -> Result<(), Box> { Ok(()) } } diff --git a/src/common.rs b/src/common.rs index c09b8c1..ab2a96b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -238,11 +238,13 @@ mod tests { fn test_trait_impls() { // make sure that all the structs implement `Send` fn is_send() {} - is_send::(); is_send::(); - is_send::>(); - is_send::(); is_send::(); - is_send::(); + #[cfg(not(target_arch = "wasm32"))] { + is_send::(); + is_send::>(); + is_send::(); + is_send::(); + } } } diff --git a/tests/virtual.rs b/tests/virtual.rs index 4e8d3fd..5ac5754 100644 --- a/tests/virtual.rs +++ b/tests/virtual.rs @@ -1,5 +1,5 @@ -//! This file contains automated tests, but they require virtual ports and therefore can't work on Windows ... -#![cfg(not(windows))] +//! This file contains automated tests, but they require virtual ports and therefore can't work on Windows or Web MIDI ... +#![cfg(not(any(windows, target_arch = "wasm32")))] extern crate midir; use std::thread::sleep;