2022-10-24 01:50:31 +02:00
|
|
|
#![deny(warnings)]
|
|
|
|
#![warn(unused_extern_crates)]
|
|
|
|
#![deny(clippy::todo)]
|
|
|
|
#![deny(clippy::unimplemented)]
|
|
|
|
#![deny(clippy::unwrap_used)]
|
|
|
|
#![deny(clippy::expect_used)]
|
|
|
|
#![deny(clippy::panic)]
|
|
|
|
#![deny(clippy::unreachable)]
|
|
|
|
#![deny(clippy::await_holding_lock)]
|
|
|
|
#![deny(clippy::needless_pass_by_value)]
|
|
|
|
#![deny(clippy::trivially_copy_pass_by_ref)]
|
|
|
|
|
|
|
|
mod entry;
|
|
|
|
|
|
|
|
#[allow(unused_extern_crates)]
|
|
|
|
extern crate proc_macro;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
2023-10-30 07:10:54 +01:00
|
|
|
use quote::quote;
|
2022-10-24 01:50:31 +02:00
|
|
|
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
|
2023-08-08 12:01:18 +02:00
|
|
|
entry::test(args, item)
|
2022-10-24 01:50:31 +02:00
|
|
|
}
|
2023-10-30 07:10:54 +01:00
|
|
|
|
|
|
|
#[proc_macro]
|
|
|
|
/// used in testkit to build and run the kanidm binary with the correct environment variables
|
|
|
|
pub fn cli_kanidm(_input: TokenStream) -> TokenStream {
|
|
|
|
let code = quote! {
|
|
|
|
{
|
|
|
|
// get the manifest path for the kanidm binary
|
|
|
|
let cli_manifest_file_path =
|
|
|
|
format!("{}/../../tools/cli/Cargo.toml", env!("CARGO_MANIFEST_DIR"));
|
|
|
|
let cli_manifest_file = std::path::Path::new(&cli_manifest_file_path)
|
|
|
|
.canonicalize()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// make sure we're building/running the current version
|
|
|
|
let mut kanidm = escargot::CargoBuild::new()
|
|
|
|
.bin("kanidm")
|
|
|
|
.current_release()
|
|
|
|
.current_target()
|
|
|
|
.manifest_path(&cli_manifest_file)
|
|
|
|
.run()
|
|
|
|
.unwrap();
|
|
|
|
let mut kanidm = kanidm.command();
|
|
|
|
kanidm.env("KANIDM_URL", &rsclient.get_url().to_string());
|
|
|
|
kanidm.env("KANIDM_TOKEN_CACHE_PATH", &token_cache_path);
|
|
|
|
kanidm
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
code.into()
|
|
|
|
}
|