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 fluence_app_service::AppServiceError;
|
||||
use fluence_app_service::MarineError;
|
||||
|
||||
use darling::Error as DarlingError;
|
||||
use syn::Error as SynError;
|
||||
@ -25,8 +26,8 @@ use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
pub enum TestGeneratorError {
|
||||
#[error("Can't load Wasm modules into Marine: {0}")]
|
||||
ITParserError(#[from] ITParserError),
|
||||
#[error("Can't load Wasm module at {0} into Marine: {1}")]
|
||||
ITParserError(PathBuf, ITParserError),
|
||||
|
||||
#[error("{0}")]
|
||||
CorruptedITSection(#[from] CorruptedITSection),
|
||||
@ -34,8 +35,11 @@ pub enum TestGeneratorError {
|
||||
#[error("{0}")]
|
||||
SynError(#[from] SynError),
|
||||
|
||||
#[error("Can't load Wasm modules from the provided config: {0}")]
|
||||
ConfigLoadError(#[from] AppServiceError),
|
||||
#[error("Can't load Wasm modules from the provided config at {0}: {1}")]
|
||||
ConfigLoadError(PathBuf, AppServiceError),
|
||||
|
||||
#[error("Can't resolve module {0} path: {1}")]
|
||||
ModuleResolveError(String, MarineError),
|
||||
|
||||
#[error("{0}")]
|
||||
AttributesError(#[from] DarlingError),
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
use crate::{TResult, TestGeneratorError};
|
||||
|
||||
use fluence_app_service::AppServiceConfig;
|
||||
use fluence_app_service::TomlAppServiceConfig;
|
||||
use marine_it_parser::module_it_interface;
|
||||
use marine_it_parser::it_interface::IModuleInterface;
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::path::{PathBuf, Path};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@ -34,77 +36,47 @@ impl<'m> Module<'m> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ConfigWrapper {
|
||||
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> {
|
||||
pub(crate) fn load_config(config_path: &str, file_path: &Path) -> TResult<AppServiceConfig> {
|
||||
let config_path_buf = file_path.join(config_path);
|
||||
|
||||
let marine_config = TomlAppServiceConfig::load(config_path_buf)?;
|
||||
let modules_dir = match resolve_modules_dir(&marine_config, modules_dir) {
|
||||
Some(modules_dir) => modules_dir,
|
||||
None => return Err(TestGeneratorError::ModulesDirUnspecified),
|
||||
};
|
||||
let mut marine_config = TomlAppServiceConfig::load(&config_path_buf)
|
||||
.map_err(|e| TestGeneratorError::ConfigLoadError(config_path_buf.clone(), e))?;
|
||||
|
||||
Ok(ConfigWrapper {
|
||||
config: marine_config,
|
||||
resolved_modules_dir: modules_dir,
|
||||
})
|
||||
marine_config.toml_marine_config.base_path = config_path_buf
|
||||
.parent()
|
||||
.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.
|
||||
pub(super) fn collect_modules<'config>(
|
||||
config: &'config TomlAppServiceConfig,
|
||||
modules_dir: &Path,
|
||||
) -> TResult<Vec<Module<'config>>> {
|
||||
let module_paths = collect_module_paths(config, modules_dir);
|
||||
pub(super) fn collect_modules(config: &AppServiceConfig) -> TResult<Vec<Module<'_>>> {
|
||||
let module_paths = collect_module_paths(config)?;
|
||||
|
||||
module_paths
|
||||
.into_iter()
|
||||
.map(|(name, path)| module_it_interface(path).map(|interface| Module::new(name, interface)))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(Into::into)
|
||||
.map(|(name, path)| {
|
||||
module_it_interface(&path)
|
||||
.map(|interface| Module::new(name, interface))
|
||||
.map_err(|e| TestGeneratorError::ITParserError(path.to_owned(), e))
|
||||
})
|
||||
.collect::<TResult<Vec<_>>>()
|
||||
}
|
||||
|
||||
fn collect_module_paths<'config>(
|
||||
config: &'config TomlAppServiceConfig,
|
||||
modules_dir: &Path,
|
||||
) -> Vec<(&'config str, PathBuf)> {
|
||||
fn collect_module_paths(config: &AppServiceConfig) -> TResult<Vec<(&str, PathBuf)>> {
|
||||
config
|
||||
.toml_marine_config
|
||||
.module
|
||||
.marine_config
|
||||
.modules_config
|
||||
.iter()
|
||||
.map(|m| {
|
||||
let module_file_name = m.file_name.as_ref().unwrap_or(&m.name);
|
||||
let module_file_name = PathBuf::from(module_file_name);
|
||||
// TODO: is it correct to always have .wasm extension?
|
||||
let module_path = modules_dir.join(module_file_name).with_extension("wasm");
|
||||
|
||||
(m.name.as_str(), module_path)
|
||||
m.get_path(&config.marine_config.modules_dir)
|
||||
.map(|path| (m.import_name.as_str(), path))
|
||||
.map_err(|e| TestGeneratorError::ModuleResolveError(m.import_name.to_owned(), e))
|
||||
})
|
||||
.collect::<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),
|
||||
}
|
||||
.collect::<TResult<Vec<_>>>()
|
||||
}
|
||||
|
@ -131,16 +131,16 @@ fn generate_test_glue_code_single_service(
|
||||
service: ServiceDescription,
|
||||
test_file_path: PathBuf,
|
||||
) -> TResult<TokenStream> {
|
||||
marine_test::utils::maybe_warn_about_modules_dir(&service);
|
||||
|
||||
let func_item = match item {
|
||||
syn::Item::Fn(func_item) => func_item,
|
||||
_ => return Err(TestGeneratorError::ExpectedFn),
|
||||
};
|
||||
|
||||
let config_wrapper =
|
||||
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_wrapper.config, &modules_dir_test_relative)?;
|
||||
let config = config_utils::load_config(&service.config_path, &test_file_path)?;
|
||||
|
||||
let module_interfaces = config_utils::collect_modules(&config)?;
|
||||
let linked_modules = marine_test::modules_linker::link_modules(
|
||||
module_interfaces
|
||||
.iter()
|
||||
@ -158,11 +158,8 @@ fn generate_test_glue_code_single_service(
|
||||
let inputs = &signature.inputs;
|
||||
let arg_names = generate_arg_names(inputs.iter())?;
|
||||
let module_ctors = generate_module_ctors(inputs.iter())?;
|
||||
let app_service_ctor = token_stream_generator::generate_app_service_ctor(
|
||||
&service.config_path,
|
||||
&config_wrapper.resolved_modules_dir,
|
||||
&test_file_path,
|
||||
)?;
|
||||
let app_service_ctor =
|
||||
token_stream_generator::generate_app_service_ctor(&service.config_path, &test_file_path)?;
|
||||
let glue_code = quote! {
|
||||
#[test]
|
||||
fn #name() {
|
||||
@ -184,7 +181,7 @@ fn generate_test_glue_code_single_service(
|
||||
#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::modules_linker::{LinkedModule, LinkedModules, UseDescription};
|
||||
use crate::marine_test::utils;
|
||||
use crate::marine_test::utils::new_ident;
|
||||
use crate::TResult;
|
||||
|
||||
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 quote::quote;
|
||||
use crate::marine_test::utils::new_ident;
|
||||
|
||||
/// Generates definitions of modules and records of this modules.
|
||||
/// F.e. for the greeting service the following definitions would be generated:
|
||||
@ -101,11 +101,11 @@ fn generate_module_definition(
|
||||
#(#module_records)*
|
||||
|
||||
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 {
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ pub(super) fn generate_module_method(
|
||||
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
||||
|
||||
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
|
||||
}
|
||||
};
|
||||
@ -65,7 +65,7 @@ pub(super) fn generate_module_method_forward(
|
||||
let (cp, func_name) = generate_call_parameters(&cp_setting, signature)?;
|
||||
|
||||
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
|
||||
}
|
||||
};
|
||||
@ -228,13 +228,7 @@ fn generate_call_parameters(
|
||||
Ok((TokenStream::new(), func_name))
|
||||
}
|
||||
CallParametersSettings::UserDefined => {
|
||||
let maybe_comma = if signature.arguments.is_empty() {
|
||||
TokenStream::new()
|
||||
} else {
|
||||
quote! { , }
|
||||
};
|
||||
|
||||
let cp = quote! { #maybe_comma cp: marine_rs_sdk_test::CallParameters };
|
||||
let cp = quote! { , cp: marine_rs_sdk_test::CallParameters, };
|
||||
let func_name = format!("{}_cp", signature.name);
|
||||
let func_name = new_ident(&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)?;
|
||||
|
||||
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")]
|
||||
pub struct #record_name_ident {
|
||||
#(pub #fields),*
|
||||
#(pub #fields,)*
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -14,13 +14,8 @@ use itertools::Itertools;
|
||||
|
||||
pub(crate) fn generate_app_service_ctor(
|
||||
config_path: &str,
|
||||
modules_dir: &Path,
|
||||
test_file_path: &Path,
|
||||
) -> 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
|
||||
.to_str()
|
||||
.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 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)
|
||||
.unwrap_or_else(|e| panic!("app service config located at `{:?}` can't be loaded: {}", config_path, e));
|
||||
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)
|
||||
} );
|
||||
__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));
|
||||
|
||||
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(
|
||||
service: &ProcessedService,
|
||||
test_file_path: &Path,
|
||||
linked_facade: &LinkedModule<'_>,
|
||||
file_path_for_app_service: &Path,
|
||||
) -> TResult<TokenStream> {
|
||||
let modules_dir_test_relative = test_file_path.join(&service.config.resolved_modules_dir);
|
||||
let modules =
|
||||
config_utils::collect_modules(&service.config.config, &modules_dir_test_relative)?;
|
||||
let modules = config_utils::collect_modules(&service.config)?;
|
||||
let linked_modules = modules_linker::link_modules(
|
||||
modules
|
||||
.iter()
|
||||
@ -106,11 +101,8 @@ pub(super) fn generate_service_definition(
|
||||
let facade_override_ident = new_ident("__facade_override")?;
|
||||
let facade_structs = generate_facade_structs(facade, &facade_override_ident)?;
|
||||
|
||||
let app_service_ctor = generate_app_service_ctor(
|
||||
&service.config_path,
|
||||
&service.config.resolved_modules_dir,
|
||||
file_path_for_app_service,
|
||||
)?;
|
||||
let app_service_ctor =
|
||||
generate_app_service_ctor(&service.config_path, file_path_for_app_service)?;
|
||||
let modules_type = generate_modules_type(&modules)?;
|
||||
|
||||
let service_definition = quote! {
|
||||
|
@ -14,14 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use crate::attributes::{ServiceDescription};
|
||||
use crate::attributes::ServiceDescription;
|
||||
use crate::TResult;
|
||||
use crate::TestGeneratorError;
|
||||
use crate::marine_test::config_utils::{Module, ConfigWrapper, load_config};
|
||||
use crate::marine_test::{modules_linker, config_utils};
|
||||
use crate::marine_test::config_utils::Module;
|
||||
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 super::service_generation_utils::generate_service_definition;
|
||||
|
||||
use fluence_app_service::AppServiceConfig;
|
||||
use marine_it_parser::it_interface::IModuleInterface;
|
||||
use proc_macro2::TokenStream;
|
||||
use itertools::Itertools;
|
||||
@ -43,9 +46,7 @@ pub(crate) fn generate_service_definitions(
|
||||
let service_modules = services
|
||||
.iter()
|
||||
.map(|service| {
|
||||
let modules_dir_test_relative = file_path.join(&service.config.resolved_modules_dir);
|
||||
let modules =
|
||||
config_utils::collect_modules(&service.config.config, &modules_dir_test_relative)?;
|
||||
let modules = config_utils::collect_modules(&service.config)?;
|
||||
Ok(modules)
|
||||
})
|
||||
.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
|
||||
generate_service_definition(
|
||||
service,
|
||||
file_path,
|
||||
link_info.get::<str>(&service.name).unwrap(),
|
||||
file_path_for_app_service,
|
||||
)
|
||||
@ -75,7 +75,7 @@ pub(super) fn get_facace<'modules, 'm>(
|
||||
}
|
||||
|
||||
pub(super) struct ProcessedService {
|
||||
pub(super) config: ConfigWrapper,
|
||||
pub(super) config: AppServiceConfig,
|
||||
pub(super) config_path: String,
|
||||
pub(super) name: String,
|
||||
}
|
||||
@ -86,7 +86,8 @@ impl ProcessedService {
|
||||
name: String,
|
||||
file_path: &Path,
|
||||
) -> 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 {
|
||||
config: config_wrapper,
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
use crate::TResult;
|
||||
use crate::ServiceDescription;
|
||||
|
||||
use marine_it_parser::it_interface::IRecordTypes;
|
||||
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)
|
||||
}
|
||||
|
||||
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,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -17,55 +17,55 @@ fn empty_string() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,>
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -101,24 +101,24 @@ fn empty_string() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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(
|
||||
&config_path
|
||||
&config_path,
|
||||
)
|
||||
.unwrap_or_else(|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.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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
|
@ -8,7 +8,7 @@ fn test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -17,56 +17,55 @@ fn test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -88,7 +87,7 @@ fn test() {
|
||||
pub fn download_cp(
|
||||
&mut self,
|
||||
url: String,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||
let result = self
|
||||
@ -133,25 +132,24 @@ fn test() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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(
|
||||
&config_path
|
||||
&config_path,
|
||||
)
|
||||
.unwrap_or_else(|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.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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
@ -162,5 +160,5 @@ fn test() {
|
||||
let _ = greeting.download("duckduckgo.com");
|
||||
}
|
||||
}
|
||||
test_func(greeting,)
|
||||
test_func(greeting)
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ pub mod tests {
|
||||
pub mod modules {
|
||||
pub mod greeting {
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct CallParameters {
|
||||
@ -19,57 +19,57 @@ pub mod tests {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||
>,
|
||||
}
|
||||
impl ModuleInterface {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -79,10 +79,10 @@ pub mod tests {
|
||||
}
|
||||
pub mod __facade_override {
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct CallParameters {
|
||||
@ -91,57 +91,56 @@ pub mod tests {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize
|
||||
Clone,
|
||||
Debug,
|
||||
marine_rs_sdk_test :: internal :: serde :: Serialize,
|
||||
marine_rs_sdk_test :: internal :: serde :: Deserialize,
|
||||
)]
|
||||
#[serde(crate = "marine_rs_sdk_test::internal::serde")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -180,7 +179,9 @@ pub mod tests {
|
||||
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 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();
|
||||
loop {
|
||||
if module_path.ends_with(file_path.as_path()) {
|
||||
@ -203,27 +204,25 @@ pub mod tests {
|
||||
module_path.push(path);
|
||||
}
|
||||
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(&config_path)
|
||||
.unwrap_or_else(|e|
|
||||
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
|
||||
)
|
||||
);
|
||||
});
|
||||
__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()
|
||||
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 modules = __GeneratedModules::new(marine.clone());
|
||||
let __facade = __facade_override::ModuleInterface::new(marine.clone());
|
||||
|
@ -10,7 +10,7 @@ fn test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -19,57 +19,57 @@ fn test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||
>,
|
||||
}
|
||||
impl ModuleInterface {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -82,7 +82,7 @@ fn test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -91,57 +91,56 @@ fn test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -180,7 +179,9 @@ fn test() {
|
||||
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 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();
|
||||
loop {
|
||||
if module_path.ends_with(file_path.as_path()) {
|
||||
@ -203,25 +204,23 @@ fn test() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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 =
|
||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
||||
.unwrap_or_else(|e|
|
||||
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
|
||||
)
|
||||
);
|
||||
});
|
||||
__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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
@ -242,7 +241,7 @@ fn test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -251,57 +250,57 @@ fn test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||
>,
|
||||
}
|
||||
impl ModuleInterface {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -323,7 +322,7 @@ fn test() {
|
||||
pub fn download_cp(
|
||||
&mut self,
|
||||
url: String,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||
let result = self
|
||||
@ -347,14 +346,13 @@ fn test() {
|
||||
pub use super::super::empty_func::SecurityTetraplet;
|
||||
pub struct ModuleInterface {
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -376,7 +374,7 @@ fn test() {
|
||||
pub fn download_cp(
|
||||
&mut self,
|
||||
url: String,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([url]);
|
||||
let result = self
|
||||
@ -424,7 +422,9 @@ fn test() {
|
||||
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 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();
|
||||
loop {
|
||||
if module_path.ends_with(file_path.as_path()) {
|
||||
@ -447,25 +447,23 @@ fn test() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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 =
|
||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
||||
.unwrap_or_else(|e|
|
||||
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
|
||||
)
|
||||
);
|
||||
});
|
||||
__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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
@ -483,7 +481,7 @@ fn test() {
|
||||
pub fn download_cp(
|
||||
&mut self,
|
||||
url: String,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
self.__facade.download_cp(url, cp,)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ fn empty_test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -19,57 +19,57 @@ fn empty_test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>
|
||||
>,
|
||||
}
|
||||
impl ModuleInterface {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -82,7 +82,7 @@ fn empty_test() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -91,57 +91,56 @@ fn empty_test() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
pub struct ModuleInterface {
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -180,7 +179,9 @@ fn empty_test() {
|
||||
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 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();
|
||||
loop {
|
||||
if module_path.ends_with(file_path.as_path()) {
|
||||
@ -203,25 +204,23 @@ fn empty_test() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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 =
|
||||
marine_rs_sdk_test::internal::TomlAppServiceConfig::load(&config_path)
|
||||
.unwrap_or_else(|e|
|
||||
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
|
||||
)
|
||||
);
|
||||
});
|
||||
__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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
|
@ -8,7 +8,7 @@ fn empty_string() {
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct CallParameters {
|
||||
@ -17,55 +17,55 @@ fn empty_string() {
|
||||
pub service_creator_peer_id: String,
|
||||
pub host_id: String,
|
||||
pub particle_id: String,
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>
|
||||
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: Vec<u8>,
|
||||
pub stderr: Vec<u8>
|
||||
pub stderr: Vec<u8>,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct MountedBinaryStringResult {
|
||||
pub ret_code: i32,
|
||||
pub error: String,
|
||||
pub stdout: String,
|
||||
pub stderr: String
|
||||
pub stderr: String,
|
||||
}
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
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")]
|
||||
pub struct SecurityTetraplet {
|
||||
pub peer_pk: String,
|
||||
pub service_id: String,
|
||||
pub function_name: String,
|
||||
pub json_path: String
|
||||
pub json_path: String,
|
||||
}
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
@ -87,7 +87,7 @@ fn empty_string() {
|
||||
pub fn greeting_cp(
|
||||
&mut self,
|
||||
name: String,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([name]);
|
||||
let result = self
|
||||
@ -107,19 +107,19 @@ fn empty_string() {
|
||||
pub use super::greeting::CallParameters;
|
||||
pub use super::greeting::SecurityTetraplet;
|
||||
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 {
|
||||
pub fn new(
|
||||
marine: std::rc::Rc<
|
||||
std::cell::RefCell<marine_rs_sdk_test::internal::AppService>,
|
||||
>
|
||||
>,
|
||||
) -> Self {
|
||||
Self { marine }
|
||||
}
|
||||
}
|
||||
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 result = self
|
||||
.marine
|
||||
@ -139,7 +139,7 @@ fn empty_string() {
|
||||
}
|
||||
pub fn call_parameters_cp(
|
||||
&mut self,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||
let result = self
|
||||
@ -153,7 +153,7 @@ fn empty_string() {
|
||||
.expect("the default deserializer shouldn't fail");
|
||||
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 result = self
|
||||
.marine
|
||||
@ -173,7 +173,7 @@ fn empty_string() {
|
||||
}
|
||||
pub fn return_string_cp(
|
||||
&mut self,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> String {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||
let result = self
|
||||
@ -187,7 +187,7 @@ fn empty_string() {
|
||||
.expect("the default deserializer shouldn't fail");
|
||||
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 result = self
|
||||
.marine
|
||||
@ -207,7 +207,7 @@ fn empty_string() {
|
||||
}
|
||||
pub fn test_array_refs_cp(
|
||||
&mut self,
|
||||
cp: marine_rs_sdk_test::CallParameters
|
||||
cp: marine_rs_sdk_test::CallParameters,
|
||||
) -> Vec<String> {
|
||||
let arguments = marine_rs_sdk_test::internal::serde_json::json!([]);
|
||||
let result = self
|
||||
@ -230,7 +230,8 @@ fn empty_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");
|
||||
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();
|
||||
loop {
|
||||
if module_path.ends_with(file_path.as_path()) {
|
||||
@ -252,25 +253,24 @@ fn empty_string() {
|
||||
module_path.push(path);
|
||||
}
|
||||
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(
|
||||
&config_path
|
||||
&config_path,
|
||||
)
|
||||
.unwrap_or_else(|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.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()
|
||||
std::collections::HashMap::new(),
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("app service can't be created: {}", e));
|
||||
let marine = std::rc::Rc::new(std::cell::RefCell::new(marine));
|
||||
@ -310,5 +310,5 @@ fn empty_string() {
|
||||
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/expanded.rs",
|
||||
"Config.toml",
|
||||
"artifacts"
|
||||
));
|
||||
}
|
||||
|
||||
@ -36,7 +35,6 @@ fn test_mounted_binary() {
|
||||
"tests/generation_tests/mounted_binary/marine_test.rs",
|
||||
"tests/generation_tests/mounted_binary/expanded.rs",
|
||||
"Config.toml",
|
||||
"artifacts"
|
||||
));
|
||||
}
|
||||
|
||||
@ -46,14 +44,12 @@ fn test_multiple_modules() {
|
||||
"tests/generation_tests/multiple_modules/marine_test.rs",
|
||||
"tests/generation_tests/multiple_modules/expanded.rs",
|
||||
"Config.toml",
|
||||
"artifacts"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiservice_single() {
|
||||
let descriptions = vec![TestServiceDescription {
|
||||
modules_dir: "empty_func/artifacts",
|
||||
config_path: "empty_func/Config.toml",
|
||||
name: "empty_func",
|
||||
}];
|
||||
@ -68,12 +64,10 @@ fn test_multiservice_single() {
|
||||
fn test_multiservice_multiple() {
|
||||
let descriptions = vec![
|
||||
TestServiceDescription {
|
||||
modules_dir: "empty_func/artifacts",
|
||||
config_path: "empty_func/Config.toml",
|
||||
name: "empty_func",
|
||||
},
|
||||
TestServiceDescription {
|
||||
modules_dir: "mounted_binary/artifacts",
|
||||
config_path: "mounted_binary/Config.toml",
|
||||
name: "mounted_binary",
|
||||
},
|
||||
@ -88,7 +82,6 @@ fn test_multiservice_multiple() {
|
||||
#[test]
|
||||
fn test_multiservice_empty_mod() {
|
||||
let descriptions = vec![TestServiceDescription {
|
||||
modules_dir: "artifacts",
|
||||
config_path: "Config.toml",
|
||||
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 std::cmp::min;
|
||||
use std::cmp::max;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn test_marine_test_token_streams<FP, EP>(
|
||||
marine_path: FP,
|
||||
expanded_path: EP,
|
||||
config_path: &str,
|
||||
modules_dir: &str,
|
||||
) -> bool
|
||||
where
|
||||
FP: AsRef<Path>,
|
||||
@ -35,7 +36,6 @@ where
|
||||
let buf = marine_path.as_ref().to_path_buf();
|
||||
let attrs = quote::quote! {
|
||||
config_path = #config_path,
|
||||
modules_dir = #modules_dir,
|
||||
};
|
||||
let marine_token_streams = marine_test_impl(
|
||||
attrs,
|
||||
@ -47,12 +47,15 @@ where
|
||||
let expanded_item = items_from_file(&expanded_path);
|
||||
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
|
||||
}
|
||||
|
||||
pub struct TestServiceDescription {
|
||||
pub config_path: &'static str,
|
||||
pub modules_dir: &'static str,
|
||||
pub name: &'static str,
|
||||
}
|
||||
|
||||
@ -72,9 +75,8 @@ where
|
||||
.iter()
|
||||
.map(|desc| {
|
||||
let config_path = desc.config_path;
|
||||
let modules_dir = desc.modules_dir;
|
||||
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>>()
|
||||
.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 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
|
||||
}
|
||||
|
||||
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