2 unstable releases

0.1.0 May 24, 2024
0.0.0 Apr 24, 2023

#2027 in Procedural macros

Download history 7/week @ 2024-03-27 17/week @ 2024-04-03 60/week @ 2024-04-10 40/week @ 2024-04-17 22/week @ 2024-04-24 17/week @ 2024-05-01 44/week @ 2024-05-08 33/week @ 2024-05-15 196/week @ 2024-05-22 29/week @ 2024-05-29 27/week @ 2024-06-05 84/week @ 2024-06-12 62/week @ 2024-06-19 73/week @ 2024-06-26

247 downloads per month
Used in hydroflow

Apache-2.0

12KB
204 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

~83KB