4 releases (breaking)

0.3.0 Nov 8, 2024
0.2.0 Aug 30, 2024
0.1.0 May 24, 2024
0.0.0 Apr 24, 2023

#2361 in Procedural macros

Download history 58/week @ 2024-08-23 195/week @ 2024-08-30 40/week @ 2024-09-06 56/week @ 2024-09-13 78/week @ 2024-09-20 100/week @ 2024-09-27 110/week @ 2024-10-04 78/week @ 2024-10-11 92/week @ 2024-10-18 68/week @ 2024-10-25 80/week @ 2024-11-01 188/week @ 2024-11-08 58/week @ 2024-11-15 103/week @ 2024-11-22 104/week @ 2024-11-29 95/week @ 2024-12-06

364 downloads per month
Used in hydroflow

Apache-2.0

12KB
203 lines

multiplatform_test

Provides a proc-macro that expands to testing on platforms relevant to Hydroflow. By default, expands to testing on the host (using the normal #[test] attribute) and wasm (using #[wasm_bindgen_test]).

For example, the test

use multiplatform_test::multiplatform_test;

#[multiplatform_test]
fn my_test() {
  // ...
}

Expands to

#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn my_test() {
  // ...
}

Installation

[dependencies]
multiplatform_test = * # replace with version.

If you're using wasm naturally you will need to add the wasm_bindgen_test crate as a dependency.

Usage

Specifying platforms

There are many platforms which can be specified:

You can test on a subset of platforms by passing in the platforms in parens:

use multiplatform_test::multiplatform_test;

#[multiplatform_test(test, env_logging)]  // Only test on the standard `#[test]` platform, but enables logging
fn my_test() {
  // ...
}

expands to

use multiplatform_test::multiplatform_test;

#[test]
fn my_test() {
  let _ = env_logger::builder().is_test(true).try_init();
  // ...
}

Dependencies

~76KB