From df091a2eb76e46923ba79f8960eb915ebb29954d Mon Sep 17 00:00:00 2001 From: "K.J. Valencik" Date: Tue, 16 Jul 2024 17:09:15 -0400 Subject: [PATCH] test(neon): Add new feature flags to the build matrix and unignore the test --- Cargo.lock | 1 + crates/neon/Cargo.toml | 1 + crates/neon/src/lib.rs | 27 ++++++++------------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 065d7b326..5884ca49b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,6 +378,7 @@ dependencies = [ "doc-comment", "easy-cast", "getrandom", + "itertools", "libloading 0.8.1", "linkify", "linkme", diff --git a/crates/neon/Cargo.toml b/crates/neon/Cargo.toml index 76429c221..4fa442453 100644 --- a/crates/neon/Cargo.toml +++ b/crates/neon/Cargo.toml @@ -11,6 +11,7 @@ exclude = ["neon.jpg", "doc/**/*"] edition = "2021" [dev-dependencies] +itertools = "0.10.5" semver = "1.0.20" psd = "0.3.4" # used for a doc example anyhow = "1.0.75" # used for a doc example diff --git a/crates/neon/src/lib.rs b/crates/neon/src/lib.rs index 1073c0a8a..13ff73251 100644 --- a/crates/neon/src/lib.rs +++ b/crates/neon/src/lib.rs @@ -149,18 +149,21 @@ pub struct Exports(()); impl Exports { /// Export all values exported with [`neon::export`](export) /// - /// ```ignore + /// ``` + /// # fn main() { /// # use neon::prelude::*; /// #[neon::main] /// fn main(mut cx: ModuleContext) -> NeonResult<()> { /// neon::registered().export(&mut cx)?; /// Ok(()) /// } + /// # } /// ``` /// /// For more control, iterate over exports. /// - /// ```ignore + /// ``` + /// # fn main() { /// # use neon::prelude::*; /// #[neon::main] /// fn main(mut cx: ModuleContext) -> NeonResult<()> { @@ -172,6 +175,7 @@ impl Exports { /// /// Ok(()) /// } + /// # } /// ``` pub fn export(self, cx: &mut ModuleContext) -> NeonResult<()> { for create in self { @@ -202,33 +206,18 @@ pub fn registered() -> Exports { } #[test] -#[ignore] fn feature_matrix() { use std::{env, process::Command}; - const EXTERNAL_BUFFERS: &str = "external-buffers"; - const FUTURES: &str = "futures"; - const SERDE: &str = "serde"; const NODE_API_VERSIONS: &[&str] = &[ "napi-1", "napi-2", "napi-3", "napi-4", "napi-5", "napi-6", "napi-7", "napi-8", ]; - // If the number of features in Neon grows, we can use `itertools` to generate permutations. - // https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.permutations - const FEATURES: &[&[&str]] = &[ - &[], - &[EXTERNAL_BUFFERS], - &[FUTURES], - &[SERDE], - &[EXTERNAL_BUFFERS, FUTURES], - &[EXTERNAL_BUFFERS, SERDE], - &[FUTURES, SERDE], - &[EXTERNAL_BUFFERS, FUTURES, SERDE], - ]; + const FEATURES: &[&str] = &["external-buffers", "futures", "serde", "tokio", "tokio-rt"]; let cargo = env::var_os("CARGO").unwrap_or_else(|| "cargo".into()); - for features in FEATURES { + for features in itertools::Itertools::powerset(FEATURES.iter()) { for version in NODE_API_VERSIONS.iter().map(|f| f.to_string()) { let features = features.iter().fold(version, |f, s| f + "," + s); let status = Command::new(&cargo)