3 releases (breaking)

0.2.0 Aug 30, 2024
0.1.0 May 24, 2024
0.0.0 Apr 24, 2023

#2123 in Procedural macros

Download history 69/week @ 2024-07-03 98/week @ 2024-07-10 77/week @ 2024-07-17 107/week @ 2024-07-24 52/week @ 2024-07-31 28/week @ 2024-08-07 23/week @ 2024-08-14 55/week @ 2024-08-21 186/week @ 2024-08-28 62/week @ 2024-09-04 34/week @ 2024-09-11 71/week @ 2024-09-18 115/week @ 2024-09-25 95/week @ 2024-10-02 80/week @ 2024-10-09 77/week @ 2024-10-16

382 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

~80KB