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 16, 2024
1 parent f7ac641 commit 0a2d57c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 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.into_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
4 changes: 2 additions & 2 deletions crates/neon/src/sys/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ macro_rules! napi_name {
///
/// Sample input:
///
/// ```ignore
/// ```skip
/// extern "C" {
/// fn get_undefined(env: Env, result: *mut Value) -> Status;
/// /* Additional functions may be included */
Expand All @@ -48,7 +48,7 @@ macro_rules! napi_name {
///
/// Generated output:
///
/// ```ignore
/// ```skip
/// // Each field is a pointer to a N-API function
/// struct Napi {
/// get_undefined: unsafe extern "C" fn(env: Env, result: *mut Value) -> Status,
Expand Down
2 changes: 1 addition & 1 deletion crates/neon/src/types_impl/buffer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ where
/// Note that, depending on the element size, this is not necessarily the same as
/// [`size()`](crate::types::buffer::TypedArray::size). In particular:
///
/// ```ignore
/// ```skip
/// self.size() == self.len() * size_of::<T>()
/// ```
#[allow(clippy::len_without_is_empty)]
Expand Down

0 comments on commit 0a2d57c

Please sign in to comment.