Skip to content

Commit

Permalink
test for default zenohd features
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Nov 27, 2023
1 parent 8ebf8b8 commit d5c95f9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 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 commons/zenoh-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ default = ["std"]
async-std = { workspace = true, features = ["default", "unstable"] }
async-trait = { workspace = true }
clap = { workspace = true }
const_format = { workspace = true }
flume = { workspace = true }
futures = { workspace = true }
hex = { workspace = true, features = ["default"] }
Expand Down
13 changes: 13 additions & 0 deletions commons/zenoh-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ extern crate alloc;
#[cfg_attr(feature = "std", macro_use)]
extern crate lazy_static;

#[macro_export]
macro_rules! concat_enabled_features {
(prefix = $prefix:literal, features = [$($feature:literal),*]) => {
{
use const_format::concatcp;
concatcp!("" $(,
if cfg!(feature = $feature) { concatcp!(" ", concatcp!($prefix, "/", $feature)) } else { "" }
)*)
}
};
}

#[deprecated = "This module is now a separate crate. Use the `zenoh_core` crate directly for shorter compile-times. You may disable this re-export by disabling `zenoh-util`'s default features."]
pub use zenoh_core as core;

Expand All @@ -30,3 +42,4 @@ mod std_only;

#[cfg(feature = "std")]
pub use std_only::*;

1 change: 1 addition & 0 deletions zenoh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async-global-executor = { workspace = true }
async-std = { workspace = true, features = ["attributes"] }
async-trait = { workspace = true }
base64 = { workspace = true }
const_format = { workspace = true }
env_logger = { workspace = true }
event-listener = { workspace = true }
flume = { workspace = true }
Expand Down
23 changes: 23 additions & 0 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ use handlers::DefaultHandler;
use net::runtime::Runtime;
use prelude::*;
use scouting::ScoutBuilder;
use zenoh_util::concat_enabled_features;
use std::future::Ready;
use zenoh_core::{AsyncResolve, Resolvable, SyncResolve};
pub use zenoh_macros::{kedefine, keformat, kewrite};
Expand All @@ -98,6 +99,28 @@ pub use zenoh_result::ZResult as Result;

const GIT_VERSION: &str = git_version!(prefix = "v", cargo_prefix = "v");

pub const FEATURES: &str = concat_enabled_features!(
prefix = "zenoh",
features = [
"auth_pubkey",
"auth_usrpwd",
"complete_n",
"shared-memory",
"stats",
"transport_multilink",
"transport_quic",
"transport_serial",
"transport_unixpipe",
"transport_tcp",
"transport_tls",
"transport_udp",
"transport_unixsock-stream",
"transport_ws",
"unstable",
"default"
]
);

mod admin;
#[macro_use]
mod session;
Expand Down
22 changes: 22 additions & 0 deletions zenohd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,25 @@ fn config_from_args(args: &ArgMatches) -> Config {
log::debug!("Config: {:?}", &config);
config
}

#[test]
fn test_default_features() {
assert_eq!(zenoh::FEATURES, concat!(
" zenoh/auth_pubkey",
" zenoh/auth_usrpwd",
// " zenoh/complete_n",
// " zenoh/shared-memory",
// " zenoh/stats",
" zenoh/transport_multilink",
" zenoh/transport_quic",
// " zenoh/transport_serial",
// " zenoh/transport_unixpipe",
" zenoh/transport_tcp",
" zenoh/transport_tls",
" zenoh/transport_udp",
" zenoh/transport_unixsock-stream",
" zenoh/transport_ws",
" zenoh/unstable",
" zenoh/default",
));
}

0 comments on commit d5c95f9

Please sign in to comment.