Skip to content

Commit

Permalink
test(neon): Add new feature flags to the build matrix and unignore th…
Browse files Browse the repository at this point in the history
…e test
  • Loading branch information
kjvalencik committed Sep 19, 2024
1 parent a518907 commit ce2eed4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/neon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 8 additions & 19 deletions crates/neon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -172,6 +175,7 @@ impl Exports {
///
/// Ok(())
/// }
/// # }
/// ```
pub fn export(self, cx: &mut ModuleContext) -> NeonResult<()> {
for create in self {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ce2eed4

Please sign in to comment.