2 unstable releases

0.1.0 May 24, 2024
0.0.0 Apr 24, 2023

#1956 in Procedural macros

Download history 28/week @ 2024-02-09 3/week @ 2024-02-16 10/week @ 2024-02-23 6/week @ 2024-03-01 17/week @ 2024-03-29 10/week @ 2024-04-05 69/week @ 2024-04-12 36/week @ 2024-04-19 15/week @ 2024-04-26 24/week @ 2024-05-03 54/week @ 2024-05-10 17/week @ 2024-05-17 209/week @ 2024-05-24

304 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