mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
feat!: use only config to load modules, deprecate modules_dir parameter (#78)
* wip * updating tests and cosmetics in codegen * all tests updated * remove extern crate core * pr fixes + fix config generated app_service loading * rework modules_dir deprecation warning * fmt * remove modules_dir from tests * pr fixes
This commit is contained in:
parent
e12f0ddc35
commit
b57fcc4ab1
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
use marine_it_parser::ITParserError;
|
use marine_it_parser::ITParserError;
|
||||||
use fluence_app_service::AppServiceError;
|
use fluence_app_service::AppServiceError;
|
||||||
|
use fluence_app_service::MarineError;
|
||||||
|
|
||||||
use darling::Error as DarlingError;
|
use darling::Error as DarlingError;
|
||||||
use syn::Error as SynError;
|
use syn::Error as SynError;
|
||||||
@ -25,8 +26,8 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
#[derive(Debug, ThisError)]
|
#[derive(Debug, ThisError)]
|
||||||
pub enum TestGeneratorError {
|
pub enum TestGeneratorError {
|
||||||
#[error("Can't load Wasm modules into Marine: {0}")]
|
#[error("Can't load Wasm module at {0} into Marine: {1}")]
|
||||||
ITParserError(#[from] ITParserError),
|
ITParserError(PathBuf, ITParserError),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
CorruptedITSection(#[from] CorruptedITSection),
|
CorruptedITSection(#[from] CorruptedITSection),
|
||||||
@ -34,8 +35,11 @@ pub enum TestGeneratorError {
|
|||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
SynError(#[from] SynError),
|
SynError(#[from] SynError),
|
||||||
|
|
||||||
#[error("Can't load Wasm modules from the provided config: {0}")]
|
#[error("Can't load Wasm modules from the provided config at {0}: {1}")]
|
||||||
ConfigLoadError(#[from] AppServiceError),
|
ConfigLoadError(PathBuf, AppServiceError),
|
||||||
|
|
||||||
|
#[error("Can't resolve module {0} path: {1}")]
|
||||||
|
ModuleResolveError(String, MarineError),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
AttributesError(#[from] DarlingError),
|
AttributesError(#[from] DarlingError),
|
||||||
|
@ -16,10 +16,12 @@
|
|||||||
|
|
||||||
use crate::{TResult, TestGeneratorError};
|
use crate::{TResult, TestGeneratorError};
|
||||||
|
|
||||||
|
use fluence_app_service::AppServiceConfig;
|
||||||
use fluence_app_service::TomlAppServiceConfig;
|
use fluence_app_service::TomlAppServiceConfig;
|
||||||
use marine_it_parser::module_it_interface;
|
use marine_it_parser::module_it_interface;
|
||||||
use marine_it_parser::it_interface::IModuleInterface;
|
use marine_it_parser::it_interface::IModuleInterface;
|
||||||
|
|
||||||
|
use std::convert::TryInto;
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
@ -34,77 +36,47 @@ impl<'m> Module<'m> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct ConfigWrapper {
|
pub(crate) fn load_config(config_path: &str, file_path: &Path) -> TResult<AppServiceConfig> {
|
||||||
pub config: TomlAppServiceConfig,
|
|
||||||
pub resolved_modules_dir: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn load_config(
|
|
||||||
config_path: &str,
|
|
||||||
modules_dir: Option<String>,
|
|
||||||
file_path: &Path,
|
|
||||||
) -> TResult<ConfigWrapper> {
|
|
||||||
let config_path_buf = file_path.join(config_path);
|
let config_path_buf = file_path.join(config_path);
|
||||||
|
|
||||||
let marine_config = TomlAppServiceConfig::load(config_path_buf)?;
|
let mut marine_config = TomlAppServiceConfig::load(&config_path_buf)
|
||||||
let modules_dir = match resolve_modules_dir(&marine_config, modules_dir) {
|
.map_err(|e| TestGeneratorError::ConfigLoadError(config_path_buf.clone(), e))?;
|
||||||
Some(modules_dir) => modules_dir,
|
|
||||||
None => return Err(TestGeneratorError::ModulesDirUnspecified),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(ConfigWrapper {
|
marine_config.toml_marine_config.base_path = config_path_buf
|
||||||
config: marine_config,
|
.parent()
|
||||||
resolved_modules_dir: modules_dir,
|
.map(PathBuf::from)
|
||||||
})
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let marine_config = marine_config
|
||||||
|
.try_into()
|
||||||
|
.map_err(|e| TestGeneratorError::ConfigLoadError(config_path_buf, e))?;
|
||||||
|
|
||||||
|
Ok(marine_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all modules the provided config consists of.
|
/// Returns all modules the provided config consists of.
|
||||||
pub(super) fn collect_modules<'config>(
|
pub(super) fn collect_modules(config: &AppServiceConfig) -> TResult<Vec<Module<'_>>> {
|
||||||
config: &'config TomlAppServiceConfig,
|
let module_paths = collect_module_paths(config)?;
|
||||||
modules_dir: &Path,
|
|
||||||
) -> TResult<Vec<Module<'config>>> {
|
|
||||||
let module_paths = collect_module_paths(config, modules_dir);
|
|
||||||
|
|
||||||
module_paths
|
module_paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, path)| module_it_interface(path).map(|interface| Module::new(name, interface)))
|
.map(|(name, path)| {
|
||||||
.collect::<Result<Vec<_>, _>>()
|
module_it_interface(&path)
|
||||||
.map_err(Into::into)
|
.map(|interface| Module::new(name, interface))
|
||||||
|
.map_err(|e| TestGeneratorError::ITParserError(path.to_owned(), e))
|
||||||
|
})
|
||||||
|
.collect::<TResult<Vec<_>>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_module_paths<'config>(
|
fn collect_module_paths(config: &AppServiceConfig) -> TResult<Vec<(&str, PathBuf)>> {
|
||||||
config: &'config TomlAppServiceConfig,
|
|
||||||
modules_dir: &Path,
|
|
||||||
) -> Vec<(&'config str, PathBuf)> {
|
|
||||||
config
|
config
|
||||||
.toml_marine_config
|
.marine_config
|
||||||
.module
|
.modules_config
|
||||||
.iter()
|
.iter()
|
||||||
.map(|m| {
|
.map(|m| {
|
||||||
let module_file_name = m.file_name.as_ref().unwrap_or(&m.name);
|
m.get_path(&config.marine_config.modules_dir)
|
||||||
let module_file_name = PathBuf::from(module_file_name);
|
.map(|path| (m.import_name.as_str(), path))
|
||||||
// TODO: is it correct to always have .wasm extension?
|
.map_err(|e| TestGeneratorError::ModuleResolveError(m.import_name.to_owned(), e))
|
||||||
let module_path = modules_dir.join(module_file_name).with_extension("wasm");
|
|
||||||
|
|
||||||
(m.name.as_str(), module_path)
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<TResult<Vec<_>>>()
|
||||||
}
|
|
||||||
|
|
||||||
/// Tries to determine a dir with compiled Wasm modules according to the following rules:
|
|
||||||
/// - if the modules_dir attribute is specified (by user) it will be chosen,
|
|
||||||
/// - otherwise if modules_dir is specified in AppService config it will be chosen,
|
|
||||||
/// - otherwise None will be returned.
|
|
||||||
pub(super) fn resolve_modules_dir(
|
|
||||||
config: &TomlAppServiceConfig,
|
|
||||||
modules_dir: Option<String>,
|
|
||||||
) -> Option<PathBuf> {
|
|
||||||
match modules_dir {
|
|
||||||
Some(modules_dir) => Some(PathBuf::from(modules_dir)),
|
|
||||||
None => config
|
|
||||||
.toml_marine_config
|
|
||||||
.modules_dir
|
|
||||||
.as_ref()
|
|
||||||
.map(PathBuf::from),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -131,16 +131,16 @@ fn generate_test_glue_code_single_service(
|
|||||||
service: ServiceDescription,
|
service: ServiceDescription,
|
||||||
test_file_path: PathBuf,
|
test_file_path: PathBuf,
|
||||||
) -> TResult<TokenStream> {
|
) -> TResult<TokenStream> {
|
||||||
|
marine_test::utils::maybe_warn_about_modules_dir(&service);
|
||||||
|
|
||||||
let func_item = match item {
|
let func_item = match item {
|
||||||
syn::Item::Fn(func_item) => func_item,
|
syn::Item::Fn(func_item) => func_item,
|
||||||
_ => return Err(TestGeneratorError::ExpectedFn),
|
_ => return Err(TestGeneratorError::ExpectedFn),
|
||||||
};
|
};
|
||||||
|
|
||||||
let config_wrapper =
|
let config = config_utils::load_config(&service.config_path, &test_file_path)?;
|
||||||
config_utils::load_config(&service.config_path, service.modules_dir, &test_file_path)?;
|
|
||||||
let modules_dir_test_relative = test_file_path.join(&config_wrapper.resolved_modules_dir);
|
let module_interfaces = config_utils::collect_modules(&config)?;
|
||||||
let module_interfaces =
|
|
||||||
config_utils::collect_modules(&config_wrapper.config, &modules_dir_test_relative)?;
|
|
||||||
let linked_modules = marine_test::modules_linker::link_modules(
|
let linked_modules = marine_test::modules_linker::link_modules(
|
||||||
module_interfaces
|
module_interfaces
|
||||||
.iter()
|
.iter()
|
||||||
@ -158,11 +158,8 @@ fn generate_test_glue_code_single_service(
|
|||||||
let inputs = &signature.inputs;
|
let inputs = &signature.inputs;
|
||||||
let arg_names = generate_arg_names(inputs.iter())?;
|
let arg_names = generate_arg_names(inputs.iter())?;
|
||||||
let module_ctors = generate_module_ctors(inputs.iter())?;
|
let module_ctors = generate_module_ctors(inputs.iter())?;
|
||||||
let app_service_ctor = token_stream_generator::generate_app_service_ctor(
|
let app_service_ctor =
|
||||||
&service.config_path,
|
token_stream_generator::generate_app_service_ctor(&service.config_path, &test_file_path)?;
|
||||||
&config_wrapper.resolved_modules_dir,
|
|
||||||
&test_file_path,
|
|
||||||
)?;
|
|
||||||
let glue_code = quote! {
|
let glue_code = quote! {
|
||||||
#[test]
|
#[test]
|
||||||
fn #name() {
|
fn #name() {
|
||||||
@ -184,7 +181,7 @@ fn generate_test_glue_code_single_service(
|
|||||||
#original_block
|
#original_block
|
||||||
}
|
}
|
||||||
|
|
||||||
test_func(#(#arg_names,)*)
|
test_func(#(#arg_names),*)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ mod service_generation_utils;
|
|||||||
use crate::marine_test::config_utils::Module;
|
use crate::marine_test::config_utils::Module;
|
||||||
use crate::marine_test::modules_linker::{LinkedModule, LinkedModules, UseDescription};
|
use crate::marine_test::modules_linker::{LinkedModule, LinkedModules, UseDescription};
|
||||||
use crate::marine_test::utils;
|
use crate::marine_test::utils;
|
||||||
|
use crate::marine_test::utils::new_ident;
|
||||||
use crate::TResult;
|
use crate::TResult;
|
||||||
|
|
||||||
pub(super) use service_generator::generate_service_definitions;
|
pub(super) use service_generator::generate_service_definitions;
|
||||||
@ -30,7 +31,6 @@ pub(super) use service_generation_utils::generate_app_service_ctor;
|
|||||||
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use crate::marine_test::utils::new_ident;
|
|
||||||
|
|
||||||
/// Generates definitions of modules and records of this modules.
|
/// Generates definitions of modules and records of this modules.
|
||||||
/// F.e. for the greeting service the following definitions would be generated:
|
/// F.e. for the greeting service the following definitions would be generated:
|
||||||
@ -101,11 +101,11 @@ fn generate_module_definition(
|
|||||||
#(#module_records)*
|
#(#module_records)*
|
||||||
|
|
||||||
pub struct #struct_ident {
|
pub struct #struct_ident {
|
||||||
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,
|
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService> >,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl #struct_ident {
|
impl #struct_ident {
|
||||||
pub fn new(marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >) -> Self {
|
pub fn new(marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ pub(super) fn generate_module_method(
|
|||||||
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
||||||
|
|
||||||
let module_method = quote! {
|
let module_method = quote! {
|
||||||
pub fn #func_name(&mut self, #(#arguments),* #cp) #output_type {
|
pub fn #func_name(&mut self #(,#arguments)* #cp) #output_type {
|
||||||
#mcall
|
#mcall
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -65,7 +65,7 @@ pub(super) fn generate_module_method_forward(
|
|||||||
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
||||||
|
|
||||||
let module_method = quote! {
|
let module_method = quote! {
|
||||||
pub fn #func_name(&mut self, #(#arguments),* #cp) #output_type {
|
pub fn #func_name(&mut self #(,#arguments)* #cp) #output_type {
|
||||||
#mcall
|
#mcall
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -228,13 +228,7 @@ fn generate_call_parameters(
|
|||||||
Ok((TokenStream::new(), func_name))
|
Ok((TokenStream::new(), func_name))
|
||||||
}
|
}
|
||||||
CallParametersSettings::UserDefined => {
|
CallParametersSettings::UserDefined => {
|
||||||
let maybe_comma = if signature.arguments.is_empty() {
|
let cp = quote! { , cp: marine_rs_sdk_test::CallParameters, };
|
||||||
TokenStream::new()
|
|
||||||
} else {
|
|
||||||
quote! { , }
|
|
||||||
};
|
|
||||||
|
|
||||||
let cp = quote! { #maybe_comma cp: marine_rs_sdk_test::CallParameters };
|
|
||||||
let func_name = format!("{}_cp", signature.name);
|
let func_name = format!("{}_cp", signature.name);
|
||||||
let func_name = new_ident(&func_name)?;
|
let func_name = new_ident(&func_name)?;
|
||||||
Ok((cp, func_name))
|
Ok((cp, func_name))
|
||||||
|
@ -42,10 +42,10 @@ pub(super) fn generate_records(
|
|||||||
let fields = prepare_field(record.record_type.fields.iter(), record.records)?;
|
let fields = prepare_field(record.record_type.fields.iter(), record.records)?;
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
#[derive(Clone, Debug, marine_rs_sdk_test::internal::serde::Serialize, marine_rs_sdk_test::internal::serde::Deserialize)]
|
#[derive(Clone, Debug, marine_rs_sdk_test::internal::serde::Serialize, marine_rs_sdk_test::internal::serde::Deserialize,)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct #record_name_ident {
|
pub struct #record_name_ident {
|
||||||
#(pub #fields),*
|
#(pub #fields,)*
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,8 @@ use itertools::Itertools;
|
|||||||
|
|
||||||
pub(crate) fn generate_app_service_ctor(
|
pub(crate) fn generate_app_service_ctor(
|
||||||
config_path: &str,
|
config_path: &str,
|
||||||
modules_dir: &Path,
|
|
||||||
test_file_path: &Path,
|
test_file_path: &Path,
|
||||||
) -> TResult<TokenStream> {
|
) -> TResult<TokenStream> {
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.ok_or_else(|| TestGeneratorError::InvalidUTF8Path(modules_dir.to_path_buf()))?;
|
|
||||||
|
|
||||||
let test_file_path = test_file_path
|
let test_file_path = test_file_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| TestGeneratorError::InvalidUTF8Path(test_file_path.to_path_buf()))?;
|
.ok_or_else(|| TestGeneratorError::InvalidUTF8Path(test_file_path.to_path_buf()))?;
|
||||||
@ -59,15 +54,18 @@ pub(crate) fn generate_app_service_ctor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let config_path = module_path.join(#config_path);
|
let config_path = module_path.join(#config_path);
|
||||||
let modules_dir = module_path.join(#modules_dir);
|
|
||||||
let modules_dir = modules_dir.to_str().expect("modules_dir contains invalid UTF8 string");
|
|
||||||
|
|
||||||
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path,)
|
||||||
.unwrap_or_else(|e| panic!("app service config located at `{:?}` can't be loaded: {}", config_path, e));
|
.unwrap_or_else(|e| {
|
||||||
|
panic!("app service config located at `{:?}` can't be loaded: {}", config_path, e)
|
||||||
|
} );
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir = Some(std::path::PathBuf::from(modules_dir));
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(__m_generated_marine_config, service_id, std::collections::HashMap::new())
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(__m_generated_marine_config, service_id, std::collections::HashMap::new(),)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
|
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
@ -78,13 +76,10 @@ pub(crate) fn generate_app_service_ctor(
|
|||||||
|
|
||||||
pub(super) fn generate_service_definition(
|
pub(super) fn generate_service_definition(
|
||||||
service: &ProcessedService,
|
service: &ProcessedService,
|
||||||
test_file_path: &Path,
|
|
||||||
linked_facade: &LinkedModule<'_>,
|
linked_facade: &LinkedModule<'_>,
|
||||||
file_path_for_app_service: &Path,
|
file_path_for_app_service: &Path,
|
||||||
) -> TResult<TokenStream> {
|
) -> TResult<TokenStream> {
|
||||||
let modules_dir_test_relative = test_file_path.join(&service.config.resolved_modules_dir);
|
let modules = config_utils::collect_modules(&service.config)?;
|
||||||
let modules =
|
|
||||||
config_utils::collect_modules(&service.config.config, &modules_dir_test_relative)?;
|
|
||||||
let linked_modules = modules_linker::link_modules(
|
let linked_modules = modules_linker::link_modules(
|
||||||
modules
|
modules
|
||||||
.iter()
|
.iter()
|
||||||
@ -106,11 +101,8 @@ pub(super) fn generate_service_definition(
|
|||||||
let facade_override_ident = new_ident("__facade_override")?;
|
let facade_override_ident = new_ident("__facade_override")?;
|
||||||
let facade_structs = generate_facade_structs(facade, &facade_override_ident)?;
|
let facade_structs = generate_facade_structs(facade, &facade_override_ident)?;
|
||||||
|
|
||||||
let app_service_ctor = generate_app_service_ctor(
|
let app_service_ctor =
|
||||||
&service.config_path,
|
generate_app_service_ctor(&service.config_path, file_path_for_app_service)?;
|
||||||
&service.config.resolved_modules_dir,
|
|
||||||
file_path_for_app_service,
|
|
||||||
)?;
|
|
||||||
let modules_type = generate_modules_type(&modules)?;
|
let modules_type = generate_modules_type(&modules)?;
|
||||||
|
|
||||||
let service_definition = quote! {
|
let service_definition = quote! {
|
||||||
|
@ -14,14 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::attributes::{ServiceDescription};
|
use crate::attributes::ServiceDescription;
|
||||||
use crate::TResult;
|
use crate::TResult;
|
||||||
use crate::TestGeneratorError;
|
use crate::TestGeneratorError;
|
||||||
use crate::marine_test::config_utils::{Module, ConfigWrapper, load_config};
|
use crate::marine_test::config_utils::Module;
|
||||||
use crate::marine_test::{modules_linker, config_utils};
|
use crate::marine_test::config_utils::load_config;
|
||||||
|
use crate::marine_test::modules_linker;
|
||||||
|
use crate::marine_test::config_utils;
|
||||||
use crate::marine_test::modules_linker::LinkedModules;
|
use crate::marine_test::modules_linker::LinkedModules;
|
||||||
use super::service_generation_utils::generate_service_definition;
|
use super::service_generation_utils::generate_service_definition;
|
||||||
|
|
||||||
|
use fluence_app_service::AppServiceConfig;
|
||||||
use marine_it_parser::it_interface::IModuleInterface;
|
use marine_it_parser::it_interface::IModuleInterface;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@ -43,9 +46,7 @@ pub(crate) fn generate_service_definitions(
|
|||||||
let service_modules = services
|
let service_modules = services
|
||||||
.iter()
|
.iter()
|
||||||
.map(|service| {
|
.map(|service| {
|
||||||
let modules_dir_test_relative = file_path.join(&service.config.resolved_modules_dir);
|
let modules = config_utils::collect_modules(&service.config)?;
|
||||||
let modules =
|
|
||||||
config_utils::collect_modules(&service.config.config, &modules_dir_test_relative)?;
|
|
||||||
Ok(modules)
|
Ok(modules)
|
||||||
})
|
})
|
||||||
.collect::<TResult<Vec<Vec<Module<'_>>>>>()?;
|
.collect::<TResult<Vec<Vec<Module<'_>>>>>()?;
|
||||||
@ -57,7 +58,6 @@ pub(crate) fn generate_service_definitions(
|
|||||||
// entry with service.name was added in link_services(...), so unwrap is safe
|
// entry with service.name was added in link_services(...), so unwrap is safe
|
||||||
generate_service_definition(
|
generate_service_definition(
|
||||||
service,
|
service,
|
||||||
file_path,
|
|
||||||
link_info.get::<str>(&service.name).unwrap(),
|
link_info.get::<str>(&service.name).unwrap(),
|
||||||
file_path_for_app_service,
|
file_path_for_app_service,
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ pub(super) fn get_facace<'modules, 'm>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct ProcessedService {
|
pub(super) struct ProcessedService {
|
||||||
pub(super) config: ConfigWrapper,
|
pub(super) config: AppServiceConfig,
|
||||||
pub(super) config_path: String,
|
pub(super) config_path: String,
|
||||||
pub(super) name: String,
|
pub(super) name: String,
|
||||||
}
|
}
|
||||||
@ -86,7 +86,8 @@ impl ProcessedService {
|
|||||||
name: String,
|
name: String,
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
) -> TResult<Self> {
|
) -> TResult<Self> {
|
||||||
let config_wrapper = load_config(&service.config_path, service.modules_dir, file_path)?;
|
crate::marine_test::utils::maybe_warn_about_modules_dir(&service);
|
||||||
|
let config_wrapper = load_config(&service.config_path, file_path)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
config: config_wrapper,
|
config: config_wrapper,
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::TResult;
|
use crate::TResult;
|
||||||
|
use crate::ServiceDescription;
|
||||||
|
|
||||||
use marine_it_parser::it_interface::IRecordTypes;
|
use marine_it_parser::it_interface::IRecordTypes;
|
||||||
use marine_it_parser::it_interface::it::IType;
|
use marine_it_parser::it_interface::it::IType;
|
||||||
|
|
||||||
@ -60,3 +62,11 @@ pub(super) fn itype_to_tokens(itype: &IType, records: &IRecordTypes) -> TResult<
|
|||||||
|
|
||||||
Ok(token_stream)
|
Ok(token_stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn maybe_warn_about_modules_dir(service: &ServiceDescription) {
|
||||||
|
if service.modules_dir.is_some() {
|
||||||
|
println!(
|
||||||
|
r#"WARNING: #[marine-test] macro attribute "modules_dir" is deprecated. It will not be used by macro. Please specify loading options in config file."#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ fn empty_string() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -17,55 +17,55 @@ fn empty_string() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,>
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -101,24 +101,24 @@ fn empty_string() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("Config.toml");
|
let config_path = module_path.join("Config.toml");
|
||||||
let modules_dir = module_path.join("artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
||||||
&config_path
|
&config_path,
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
));
|
)
|
||||||
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir = Some(std::path::PathBuf::from(modules_dir));
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
|
@ -8,7 +8,7 @@ fn test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -17,56 +17,55 @@ fn test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -88,7 +87,7 @@ fn test() {
|
|||||||
pub fn download_cp(
|
pub fn download_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
url: String,
|
url: String,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -133,25 +132,24 @@ fn test() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("Config.toml");
|
let config_path = module_path.join("Config.toml");
|
||||||
let modules_dir = module_path.join("artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
||||||
&config_path
|
&config_path,
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir = Some(std::path::PathBuf::from(modules_dir));
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
@ -162,5 +160,5 @@ fn test() {
|
|||||||
let _ = greeting.download("duckduckgo.com");
|
let _ = greeting.download("duckduckgo.com");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test_func(greeting,)
|
test_func(greeting)
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ pub mod tests {
|
|||||||
pub mod modules {
|
pub mod modules {
|
||||||
pub mod greeting {
|
pub mod greeting {
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -19,57 +19,57 @@ pub mod tests {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -79,10 +79,10 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
pub mod __facade_override {
|
pub mod __facade_override {
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -91,57 +91,56 @@ pub mod tests {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine:
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService> >,
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -180,7 +179,9 @@ pub mod tests {
|
|||||||
std::fs::create_dir(&tmp_dir)
|
std::fs::create_dir(&tmp_dir)
|
||||||
.expect("can't create a directory for service in tmp");
|
.expect("can't create a directory for service in tmp");
|
||||||
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let mut file_path = std::path::Path::new("tests/generation_tests/multi-service-empty_mod").components();
|
let mut file_path =
|
||||||
|
std::path::Path::new("tests/generation_tests/multi-service-empty_mod")
|
||||||
|
.components();
|
||||||
let mut truncated_file_path = Vec::new();
|
let mut truncated_file_path = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if module_path.ends_with(file_path.as_path()) {
|
if module_path.ends_with(file_path.as_path()) {
|
||||||
@ -203,27 +204,25 @@ pub mod tests {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("Config.toml");
|
let config_path = module_path.join("Config.toml");
|
||||||
let modules_dir = module_path.join("artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config =
|
let mut __m_generated_marine_config =
|
||||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path,)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir =
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
Some(std::path::PathBuf::from(modules_dir));
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
let modules = __GeneratedModules::new(marine.clone());
|
let modules = __GeneratedModules::new(marine.clone());
|
||||||
let __facade = __facade_override::ModuleInterface::new(marine.clone());
|
let __facade = __facade_override::ModuleInterface::new(marine.clone());
|
||||||
|
@ -10,7 +10,7 @@ fn test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -19,57 +19,57 @@ fn test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ fn test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -91,57 +91,56 @@ fn test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine:
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService> >,
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -180,7 +179,9 @@ fn test() {
|
|||||||
std::fs::create_dir(&tmp_dir)
|
std::fs::create_dir(&tmp_dir)
|
||||||
.expect("can't create a directory for service in tmp");
|
.expect("can't create a directory for service in tmp");
|
||||||
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let mut file_path = std::path::Path::new("tests/generation_tests/multi-service-multiple").components();
|
let mut file_path =
|
||||||
|
std::path::Path::new("tests/generation_tests/multi-service-multiple")
|
||||||
|
.components();
|
||||||
let mut truncated_file_path = Vec::new();
|
let mut truncated_file_path = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if module_path.ends_with(file_path.as_path()) {
|
if module_path.ends_with(file_path.as_path()) {
|
||||||
@ -203,25 +204,23 @@ fn test() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("empty_func/Config.toml");
|
let config_path = module_path.join("empty_func/Config.toml");
|
||||||
let modules_dir = module_path.join("empty_func/artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config =
|
let mut __m_generated_marine_config =
|
||||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path,)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir =
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
Some(std::path::PathBuf::from(modules_dir));
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
@ -242,7 +241,7 @@ fn test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -251,57 +250,57 @@ fn test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -323,7 +322,7 @@ fn test() {
|
|||||||
pub fn download_cp(
|
pub fn download_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
url: String,
|
url: String,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -347,14 +346,13 @@ fn test() {
|
|||||||
pub use super::super::empty_func::SecurityTetraplet;
|
pub use super::super::empty_func::SecurityTetraplet;
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine:
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -376,7 +374,7 @@ fn test() {
|
|||||||
pub fn download_cp(
|
pub fn download_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
url: String,
|
url: String,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -424,7 +422,9 @@ fn test() {
|
|||||||
std::fs::create_dir(&tmp_dir)
|
std::fs::create_dir(&tmp_dir)
|
||||||
.expect("can't create a directory for service in tmp");
|
.expect("can't create a directory for service in tmp");
|
||||||
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let mut file_path = std::path::Path::new("tests/generation_tests/multi-service-multiple").components();
|
let mut file_path =
|
||||||
|
std::path::Path::new("tests/generation_tests/multi-service-multiple")
|
||||||
|
.components();
|
||||||
let mut truncated_file_path = Vec::new();
|
let mut truncated_file_path = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if module_path.ends_with(file_path.as_path()) {
|
if module_path.ends_with(file_path.as_path()) {
|
||||||
@ -447,25 +447,23 @@ fn test() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("mounted_binary/Config.toml");
|
let config_path = module_path.join("mounted_binary/Config.toml");
|
||||||
let modules_dir = module_path.join("mounted_binary/artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config =
|
let mut __m_generated_marine_config =
|
||||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path,)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir =
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
Some(std::path::PathBuf::from(modules_dir));
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
@ -483,7 +481,7 @@ fn test() {
|
|||||||
pub fn download_cp(
|
pub fn download_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
url: String,
|
url: String,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
self.__facade.download_cp(url, cp,)
|
self.__facade.download_cp(url, cp,)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ fn empty_test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -19,57 +19,57 @@ fn empty_test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ fn empty_test() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -91,57 +91,56 @@ fn empty_test() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine:
|
marine:
|
||||||
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -180,7 +179,9 @@ fn empty_test() {
|
|||||||
std::fs::create_dir(&tmp_dir)
|
std::fs::create_dir(&tmp_dir)
|
||||||
.expect("can't create a directory for service in tmp");
|
.expect("can't create a directory for service in tmp");
|
||||||
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let mut file_path = std::path::Path::new("tests/generation_tests/multi-service-single").components();
|
let mut file_path =
|
||||||
|
std::path::Path::new("tests/generation_tests/multi-service-single")
|
||||||
|
.components();
|
||||||
let mut truncated_file_path = Vec::new();
|
let mut truncated_file_path = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if module_path.ends_with(file_path.as_path()) {
|
if module_path.ends_with(file_path.as_path()) {
|
||||||
@ -203,25 +204,23 @@ fn empty_test() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("empty_func/Config.toml");
|
let config_path = module_path.join("empty_func/Config.toml");
|
||||||
let modules_dir = module_path.join("empty_func/artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config =
|
let mut __m_generated_marine_config =
|
||||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path, )
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir =
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
Some(std::path::PathBuf::from(modules_dir));
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
|
@ -8,7 +8,7 @@ fn empty_string() {
|
|||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct CallParameters {
|
pub struct CallParameters {
|
||||||
@ -17,55 +17,55 @@ fn empty_string() {
|
|||||||
pub service_creator_peer_id: String,
|
pub service_creator_peer_id: String,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub particle_id: String,
|
pub particle_id: String,
|
||||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryResult {
|
pub struct MountedBinaryResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: Vec<u8>,
|
pub stdout: Vec<u8>,
|
||||||
pub stderr: Vec<u8>
|
pub stderr: Vec<u8>,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct MountedBinaryStringResult {
|
pub struct MountedBinaryStringResult {
|
||||||
pub ret_code: i32,
|
pub ret_code: i32,
|
||||||
pub error: String,
|
pub error: String,
|
||||||
pub stdout: String,
|
pub stdout: String,
|
||||||
pub stderr: String
|
pub stderr: String,
|
||||||
}
|
}
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||||
)]
|
)]
|
||||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||||
pub struct SecurityTetraplet {
|
pub struct SecurityTetraplet {
|
||||||
pub peer_pk: String,
|
pub peer_pk: String,
|
||||||
pub service_id: String,
|
pub service_id: String,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
pub json_path: String
|
pub json_path: String,
|
||||||
}
|
}
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,
|
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ fn empty_string() {
|
|||||||
pub fn greeting_cp(
|
pub fn greeting_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: String,
|
name: String,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([name]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([name]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -107,19 +107,19 @@ fn empty_string() {
|
|||||||
pub use super::greeting::CallParameters;
|
pub use super::greeting::CallParameters;
|
||||||
pub use super::greeting::SecurityTetraplet;
|
pub use super::greeting::SecurityTetraplet;
|
||||||
pub struct ModuleInterface {
|
pub struct ModuleInterface {
|
||||||
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>, >,
|
marine: std::rc::Rc<std::cell::RefCell<marine_rs_sdk_test::internal::AppService>>,
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
marine: std::rc::Rc<
|
marine: std::rc::Rc<
|
||||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||||
>
|
>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { marine }
|
Self { marine }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ModuleInterface {
|
impl ModuleInterface {
|
||||||
pub fn call_parameters(&mut self, ) -> String {
|
pub fn call_parameters(&mut self) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
.marine
|
.marine
|
||||||
@ -139,7 +139,7 @@ fn empty_string() {
|
|||||||
}
|
}
|
||||||
pub fn call_parameters_cp(
|
pub fn call_parameters_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -153,7 +153,7 @@ fn empty_string() {
|
|||||||
.expect("the default deserializer shouldn't fail");
|
.expect("the default deserializer shouldn't fail");
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
pub fn return_string(&mut self,) -> String {
|
pub fn return_string(&mut self) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
.marine
|
.marine
|
||||||
@ -173,7 +173,7 @@ fn empty_string() {
|
|||||||
}
|
}
|
||||||
pub fn return_string_cp(
|
pub fn return_string_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> String {
|
) -> String {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -187,7 +187,7 @@ fn empty_string() {
|
|||||||
.expect("the default deserializer shouldn't fail");
|
.expect("the default deserializer shouldn't fail");
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
pub fn test_array_refs(&mut self, ) -> Vec<String> {
|
pub fn test_array_refs(&mut self) -> Vec<String> {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
.marine
|
.marine
|
||||||
@ -207,7 +207,7 @@ fn empty_string() {
|
|||||||
}
|
}
|
||||||
pub fn test_array_refs_cp(
|
pub fn test_array_refs_cp(
|
||||||
&mut self,
|
&mut self,
|
||||||
cp: marine_rs_sdk_test::CallParameters
|
cp: marine_rs_sdk_test::CallParameters,
|
||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||||
let result = self
|
let result = self
|
||||||
@ -230,7 +230,8 @@ fn empty_string() {
|
|||||||
let tmp_dir = tmp_dir.to_string_lossy().to_string();
|
let tmp_dir = tmp_dir.to_string_lossy().to_string();
|
||||||
std::fs::create_dir(&tmp_dir).expect("can't create a directory for service in tmp");
|
std::fs::create_dir(&tmp_dir).expect("can't create a directory for service in tmp");
|
||||||
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut module_path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let mut file_path = std::path::Path::new("tests/generation_tests/multiple_modules").components();
|
let mut file_path =
|
||||||
|
std::path::Path::new("tests/generation_tests/multiple_modules").components();
|
||||||
let mut truncated_file_path = Vec::new();
|
let mut truncated_file_path = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
if module_path.ends_with(file_path.as_path()) {
|
if module_path.ends_with(file_path.as_path()) {
|
||||||
@ -252,25 +253,24 @@ fn empty_string() {
|
|||||||
module_path.push(path);
|
module_path.push(path);
|
||||||
}
|
}
|
||||||
let config_path = module_path.join("Config.toml");
|
let config_path = module_path.join("Config.toml");
|
||||||
let modules_dir = module_path.join("artifacts");
|
|
||||||
let modules_dir = modules_dir
|
|
||||||
.to_str()
|
|
||||||
.expect("modules_dir contains invalid UTF8 string");
|
|
||||||
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
let mut __m_generated_marine_config = marine_rs_sdk_test::internal::TomlAppServiceConfig::load(
|
||||||
&config_path
|
&config_path,
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e|
|
.unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"app service config located at `{:?}` can't be loaded: {}",
|
"app service config located at `{:?}` can't be loaded: {}",
|
||||||
config_path, e
|
config_path, e
|
||||||
)
|
)
|
||||||
);
|
});
|
||||||
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
__m_generated_marine_config.service_base_dir = Some(tmp_dir);
|
||||||
__m_generated_marine_config.toml_marine_config.modules_dir = Some(std::path::PathBuf::from(modules_dir));
|
__m_generated_marine_config.toml_marine_config.base_path = config_path
|
||||||
|
.parent()
|
||||||
|
.map(std::path::PathBuf::from)
|
||||||
|
.unwrap_or_default();
|
||||||
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
let marine = marine_rs_sdk_test::internal::AppService::new_with_empty_facade(
|
||||||
__m_generated_marine_config,
|
__m_generated_marine_config,
|
||||||
service_id,
|
service_id,
|
||||||
std::collections::HashMap::new()
|
std::collections::HashMap::new(),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||||
@ -310,5 +310,5 @@ fn empty_string() {
|
|||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test_func(greeting_m, call_parameters_m, )
|
test_func(greeting_m, call_parameters_m)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ fn test_empty_func() {
|
|||||||
"tests/generation_tests/empty_func/marine_test.rs",
|
"tests/generation_tests/empty_func/marine_test.rs",
|
||||||
"tests/generation_tests/empty_func/expanded.rs",
|
"tests/generation_tests/empty_func/expanded.rs",
|
||||||
"Config.toml",
|
"Config.toml",
|
||||||
"artifacts"
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ fn test_mounted_binary() {
|
|||||||
"tests/generation_tests/mounted_binary/marine_test.rs",
|
"tests/generation_tests/mounted_binary/marine_test.rs",
|
||||||
"tests/generation_tests/mounted_binary/expanded.rs",
|
"tests/generation_tests/mounted_binary/expanded.rs",
|
||||||
"Config.toml",
|
"Config.toml",
|
||||||
"artifacts"
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,14 +44,12 @@ fn test_multiple_modules() {
|
|||||||
"tests/generation_tests/multiple_modules/marine_test.rs",
|
"tests/generation_tests/multiple_modules/marine_test.rs",
|
||||||
"tests/generation_tests/multiple_modules/expanded.rs",
|
"tests/generation_tests/multiple_modules/expanded.rs",
|
||||||
"Config.toml",
|
"Config.toml",
|
||||||
"artifacts"
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multiservice_single() {
|
fn test_multiservice_single() {
|
||||||
let descriptions = vec![TestServiceDescription {
|
let descriptions = vec![TestServiceDescription {
|
||||||
modules_dir: "empty_func/artifacts",
|
|
||||||
config_path: "empty_func/Config.toml",
|
config_path: "empty_func/Config.toml",
|
||||||
name: "empty_func",
|
name: "empty_func",
|
||||||
}];
|
}];
|
||||||
@ -68,12 +64,10 @@ fn test_multiservice_single() {
|
|||||||
fn test_multiservice_multiple() {
|
fn test_multiservice_multiple() {
|
||||||
let descriptions = vec![
|
let descriptions = vec![
|
||||||
TestServiceDescription {
|
TestServiceDescription {
|
||||||
modules_dir: "empty_func/artifacts",
|
|
||||||
config_path: "empty_func/Config.toml",
|
config_path: "empty_func/Config.toml",
|
||||||
name: "empty_func",
|
name: "empty_func",
|
||||||
},
|
},
|
||||||
TestServiceDescription {
|
TestServiceDescription {
|
||||||
modules_dir: "mounted_binary/artifacts",
|
|
||||||
config_path: "mounted_binary/Config.toml",
|
config_path: "mounted_binary/Config.toml",
|
||||||
name: "mounted_binary",
|
name: "mounted_binary",
|
||||||
},
|
},
|
||||||
@ -88,7 +82,6 @@ fn test_multiservice_multiple() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_multiservice_empty_mod() {
|
fn test_multiservice_empty_mod() {
|
||||||
let descriptions = vec![TestServiceDescription {
|
let descriptions = vec![TestServiceDescription {
|
||||||
modules_dir: "artifacts",
|
|
||||||
config_path: "Config.toml",
|
config_path: "Config.toml",
|
||||||
name: "empty_mod",
|
name: "empty_mod",
|
||||||
}];
|
}];
|
||||||
|
@ -18,13 +18,14 @@ use marine_test_macro_impl::marine_test_impl;
|
|||||||
|
|
||||||
use marine_macro_testing_utils::{items_from_file, stream_from_file, to_syn_item};
|
use marine_macro_testing_utils::{items_from_file, stream_from_file, to_syn_item};
|
||||||
|
|
||||||
|
use std::cmp::min;
|
||||||
|
use std::cmp::max;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn test_marine_test_token_streams<FP, EP>(
|
pub fn test_marine_test_token_streams<FP, EP>(
|
||||||
marine_path: FP,
|
marine_path: FP,
|
||||||
expanded_path: EP,
|
expanded_path: EP,
|
||||||
config_path: &str,
|
config_path: &str,
|
||||||
modules_dir: &str,
|
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
FP: AsRef<Path>,
|
FP: AsRef<Path>,
|
||||||
@ -35,7 +36,6 @@ where
|
|||||||
let buf = marine_path.as_ref().to_path_buf();
|
let buf = marine_path.as_ref().to_path_buf();
|
||||||
let attrs = quote::quote! {
|
let attrs = quote::quote! {
|
||||||
config_path = #config_path,
|
config_path = #config_path,
|
||||||
modules_dir = #modules_dir,
|
|
||||||
};
|
};
|
||||||
let marine_token_streams = marine_test_impl(
|
let marine_token_streams = marine_test_impl(
|
||||||
attrs,
|
attrs,
|
||||||
@ -47,12 +47,15 @@ where
|
|||||||
let expanded_item = items_from_file(&expanded_path);
|
let expanded_item = items_from_file(&expanded_path);
|
||||||
let marine_item = to_syn_item(marine_token_streams.clone());
|
let marine_item = to_syn_item(marine_token_streams.clone());
|
||||||
|
|
||||||
|
if expanded_item != marine_item {
|
||||||
|
print_token_streams_with_diff(&marine_token_streams, &expanded_path);
|
||||||
|
}
|
||||||
|
|
||||||
marine_item == expanded_item
|
marine_item == expanded_item
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TestServiceDescription {
|
pub struct TestServiceDescription {
|
||||||
pub config_path: &'static str,
|
pub config_path: &'static str,
|
||||||
pub modules_dir: &'static str,
|
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +75,8 @@ where
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|desc| {
|
.map(|desc| {
|
||||||
let config_path = desc.config_path;
|
let config_path = desc.config_path;
|
||||||
let modules_dir = desc.modules_dir;
|
|
||||||
let name = syn::parse_str::<syn::Ident>(desc.name)?;
|
let name = syn::parse_str::<syn::Ident>(desc.name)?;
|
||||||
Ok(quote::quote! {#name(config_path = #config_path, modules_dir = #modules_dir)})
|
Ok(quote::quote! {#name(config_path = #config_path)})
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, syn::Error>>()
|
.collect::<Result<Vec<_>, syn::Error>>()
|
||||||
.unwrap_or_else(|e| panic!("failed to parse test arguments due to {}", e));
|
.unwrap_or_else(|e| panic!("failed to parse test arguments due to {}", e));
|
||||||
@ -93,5 +95,32 @@ where
|
|||||||
let expanded_item = items_from_file(&expanded_path);
|
let expanded_item = items_from_file(&expanded_path);
|
||||||
let marine_item = to_syn_item(marine_token_streams.clone());
|
let marine_item = to_syn_item(marine_token_streams.clone());
|
||||||
|
|
||||||
|
if expanded_item != marine_item {
|
||||||
|
print_token_streams_with_diff(&marine_token_streams, &expanded_path);
|
||||||
|
}
|
||||||
|
|
||||||
marine_item == expanded_item
|
marine_item == expanded_item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_token_streams_with_diff<P: AsRef<Path>>(
|
||||||
|
macro_output: &proc_macro2::TokenStream,
|
||||||
|
expanded_path: P,
|
||||||
|
) {
|
||||||
|
let actual = macro_output.to_string();
|
||||||
|
let expected = stream_from_file(&expanded_path).to_string();
|
||||||
|
let min_len = min(actual.len(), expected.len());
|
||||||
|
let max_len = max(actual.len(), expected.len());
|
||||||
|
let mut first_diff_index: usize = min_len;
|
||||||
|
for i in 0..min_len {
|
||||||
|
// String does not implement index access, but implements range access
|
||||||
|
if actual[i..i + 1] != expected[i..i + 1] {
|
||||||
|
first_diff_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let diff = " ".repeat(first_diff_index) + &"^".repeat(max_len - first_diff_index);
|
||||||
|
|
||||||
|
println!("actual : {}", &actual);
|
||||||
|
println!("expected: {}", &expected);
|
||||||
|
println!("diff : {}", &diff);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user