Skip to content

Commit

Permalink
Fixed wasm tests not running due to incorrect attribute target.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmusick committed Jun 21, 2023
1 parent 07052be commit 9366f01
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ version = "1.0.56"
package = "wasm-bindgen"
version = "0.2"

[target.'cfg(target = "wasm32-unknown-unknown")'.dev-dependencies.wasm-bindgen-test]
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dev-dependencies.wasm-bindgen-test]
version = "0.3"

[dev-dependencies.trybuild]
Expand Down
76 changes: 38 additions & 38 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ mod tests {

use crate::std::string::{String, ToString};

#[cfg(target = "wasm32-unknown-unknown")]
#[cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))]
use wasm_bindgen_test::*;

macro_rules! check {
Expand All @@ -976,7 +976,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_compare() {
let uuid1 = new();
let uuid2 = new2();
Expand All @@ -989,7 +989,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_default() {
let default_uuid = Uuid::default();
let nil_uuid = Uuid::nil();
Expand All @@ -998,7 +998,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_display() {
use crate::std::fmt::Write;

Expand All @@ -1014,7 +1014,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_lowerhex() {
use crate::std::fmt::Write;

Expand All @@ -1028,7 +1028,7 @@ mod tests {

// noinspection RsAssertEqual
#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_operator_eq() {
let uuid1 = new();
let uuid1_dup = uuid1.clone();
Expand All @@ -1045,7 +1045,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_uuid_to_string() {
use crate::std::fmt::Write;

Expand All @@ -1061,7 +1061,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_non_conforming() {
let from_bytes =
Uuid::from_bytes([4, 54, 67, 12, 43, 2, 2, 76, 32, 50, 87, 5, 1, 33, 43, 87]);
Expand All @@ -1070,7 +1070,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_nil() {
let nil = Uuid::nil();
let not_nil = new();
Expand All @@ -1091,7 +1091,7 @@ mod tests {

#[test]
#[cfg(uuid_unstable)]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_max() {
let max = Uuid::max();
let not_max = new();
Expand All @@ -1111,7 +1111,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_predefined_namespaces() {
assert_eq!(
Uuid::NAMESPACE_DNS.hyphenated().to_string(),
Expand All @@ -1133,7 +1133,7 @@ mod tests {

#[cfg(feature = "v3")]
#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_get_version_v3() {
let uuid = Uuid::new_v3(&Uuid::NAMESPACE_DNS, "rust-lang.org".as_bytes());

Expand All @@ -1142,7 +1142,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_get_variant() {
let uuid1 = new();
let uuid2 = Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000").unwrap();
Expand All @@ -1160,7 +1160,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_to_simple_string() {
let uuid1 = new();
let s = uuid1.simple().to_string();
Expand All @@ -1170,7 +1170,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_hyphenated_string() {
let uuid1 = new();
let s = uuid1.hyphenated().to_string();
Expand All @@ -1180,7 +1180,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_upper_lower_hex() {
use std::fmt::Write;

Expand Down Expand Up @@ -1233,7 +1233,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_to_urn_string() {
let uuid1 = new();
let ss = uuid1.urn().to_string();
Expand All @@ -1245,7 +1245,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_to_simple_string_matching() {
let uuid1 = new();

Expand All @@ -1258,7 +1258,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_string_roundtrip() {
let uuid = new();

Expand All @@ -1272,7 +1272,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_fields() {
let d1: u32 = 0xa1a2a3a4;
let d2: u16 = 0xb1b2;
Expand All @@ -1287,7 +1287,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_fields_le() {
let d1: u32 = 0xa4a3a2a1;
let d2: u16 = 0xb2b1;
Expand All @@ -1302,7 +1302,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_as_fields() {
let u = new();
let (d1, d2, d3, d4) = u.as_fields();
Expand All @@ -1315,7 +1315,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_fields_roundtrip() {
let d1_in: u32 = 0xa1a2a3a4;
let d2_in: u16 = 0xb1b2;
Expand All @@ -1332,7 +1332,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_fields_le_roundtrip() {
let d1_in: u32 = 0xa4a3a2a1;
let d2_in: u16 = 0xb2b1;
Expand All @@ -1349,7 +1349,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_fields_le_are_actually_le() {
let d1_in: u32 = 0xa1a2a3a4;
let d2_in: u16 = 0xb1b2;
Expand All @@ -1366,7 +1366,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_u128() {
let v_in: u128 = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8;

Expand All @@ -1378,7 +1378,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_u128_le() {
let v_in: u128 = 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1;

Expand All @@ -1390,7 +1390,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_u64_pair() {
let high_in: u64 = 0xa1a2a3a4b1b2c1c2;
let low_in: u64 = 0xd1d2d3d4d5d6d7d8;
Expand All @@ -1403,7 +1403,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_u128_roundtrip() {
let v_in: u128 = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8;

Expand All @@ -1414,7 +1414,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_u128_le_roundtrip() {
let v_in: u128 = 0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1;

Expand All @@ -1425,7 +1425,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_u64_pair_roundtrip() {
let high_in: u64 = 0xa1a2a3a4b1b2c1c2;
let low_in: u64 = 0xd1d2d3d4d5d6d7d8;
Expand All @@ -1438,7 +1438,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_u128_le_is_actually_le() {
let v_in: u128 = 0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8;

Expand All @@ -1449,7 +1449,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_slice() {
let b = [
0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
Expand All @@ -1463,7 +1463,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_from_bytes() {
let b = [
0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
Expand All @@ -1477,7 +1477,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_as_bytes() {
let u = new();
let ub = u.as_bytes();
Expand All @@ -1490,7 +1490,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_bytes_roundtrip() {
let b_in: crate::Bytes = [
0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
Expand All @@ -1505,7 +1505,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_bytes_le_roundtrip() {
let b = [
0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
Expand All @@ -1522,7 +1522,7 @@ mod tests {
}

#[test]
#[cfg_attr(target = "wasm32-unknown-unknown", wasm_bindgen_test)]
#[cfg_attr(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"), wasm_bindgen_test)]
fn test_iterbytes_impl_for_uuid() {
let mut set = std::collections::HashSet::new();
let id1 = new();
Expand Down
4 changes: 2 additions & 2 deletions src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub(crate) const fn decode_unix_timestamp_millis(uuid: &Uuid) -> u64 {
millis
}

#[cfg(all(feature = "std", feature = "js", target = "wasm32-unknown-unknown"))]
#[cfg(all(feature = "std", feature = "js", all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown")))]
fn now() -> (u64, u32) {
use wasm_bindgen::prelude::*;

Expand All @@ -280,7 +280,7 @@ fn now() -> (u64, u32) {
dbg!((secs, nanos))
}

#[cfg(all(feature = "std", any(not(feature = "js"), not(target = "wasm32-unknown-unknown"))))]
#[cfg(all(feature = "std", any(not(feature = "js"), not(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown")))))]
fn now() -> (u64, u32) {
let dur = std::time::SystemTime::UNIX_EPOCH
.elapsed()
Expand Down
Loading

0 comments on commit 9366f01

Please sign in to comment.