Skip to content

Commit

Permalink
Fix wasm-pack test, disable test_forward/systex.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaulingMonkey committed Sep 1, 2019
1 parent e36019c commit 155b3ce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ web-sys = { version = "0.3", features = [
"MidiPort",
"MidiPortType"
]}

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.2"
9 changes: 8 additions & 1 deletion examples/test_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Error>> {
let mut input = String::new();

Expand Down Expand Up @@ -61,4 +62,10 @@ fn run() -> Result<(), Box<Error>> {

println!("Closing connections");
Ok(())
}
}

#[cfg(target_arch = "wasm32")]
fn run() -> Result<(), Box<Error>> {
println!("test_forward cannot run on Web MIDI");
Ok(())
}
4 changes: 2 additions & 2 deletions examples/test_sysex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn run() -> Result<(), Box<Error>> {
}

// 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<Error>> { Ok(()) }
}
10 changes: 6 additions & 4 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ mod tests {
fn test_trait_impls() {
// make sure that all the structs implement `Send`
fn is_send<T: Send>() {}
is_send::<MidiInputPort>();
is_send::<MidiInput>();
is_send::<MidiInputConnection<()>>();
is_send::<MidiOutputPort>();
is_send::<MidiOutput>();
is_send::<MidiOutputConnection>();
#[cfg(not(target_arch = "wasm32"))] {
is_send::<MidiInputPort>();
is_send::<MidiInputConnection<()>>();
is_send::<MidiOutputPort>();
is_send::<MidiOutputConnection>();
}
}
}
4 changes: 2 additions & 2 deletions tests/virtual.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 155b3ce

Please sign in to comment.