rename full_path to file_path

This commit is contained in:
vms 2021-04-29 10:35:00 +03:00
parent a237bf442d
commit 40fdbb7bb6
3 changed files with 9 additions and 8 deletions

View File

@ -26,7 +26,7 @@ use std::path::PathBuf;
pub fn fce_test_impl(
attrs: TokenStream,
input: TokenStream,
full_path: PathBuf,
file_path: PathBuf,
) -> TResult<TokenStream> {
// from https://github.com/dtolnay/syn/issues/788
let parser = syn::punctuated::Punctuated::<syn::NestedMeta, syn::Token![,]>::parse_terminated;
@ -36,5 +36,5 @@ pub fn fce_test_impl(
let func_item = syn::parse2::<syn::ItemFn>(input)?;
generate_test_glue_code(func_item, attrs, full_path)
generate_test_glue_code(func_item, attrs, file_path)
}

View File

@ -114,9 +114,9 @@ use std::path::PathBuf;
pub(super) fn generate_test_glue_code(
func_item: syn::ItemFn,
attrs: FCETestAttributes,
full_path: PathBuf,
file_path: PathBuf,
) -> TResult<TokenStream> {
let config_path = full_path.join(&attrs.config_path);
let config_path = file_path.join(&attrs.config_path);
let fce_config = TomlAppServiceConfig::load(&config_path)?;
let modules_dir = match config_utils::resolve_modules_dir(&fce_config, attrs.modules_dir) {
@ -125,7 +125,7 @@ pub(super) fn generate_test_glue_code(
};
let app_service_ctor = generate_app_service_ctor(&attrs.config_path, &modules_dir)?;
let modules_dir = full_path.join(modules_dir);
let modules_dir = file_path.join(modules_dir);
let module_interfaces = fce_test::config_utils::collect_modules(&fce_config, modules_dir)?;
let module_definitions =

View File

@ -46,10 +46,11 @@ use syn::spanned::Spanned;
pub fn fce_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
let attrs: proc_macro2::TokenStream = attrs.into();
let attrs_span = attrs.span();
let mut full_path = proc_macro::Span::call_site().source_file().path();
let _ = full_path.pop();
// here it obtains a path to the current file where macro is applied
let mut file_path = proc_macro::Span::call_site().source_file().path();
let _ = file_path.pop();
match fce_test_impl(attrs, input.into(), full_path) {
match fce_test_impl(attrs, input.into(), file_path) {
Ok(stream) => stream.into(),
Err(e) => proc_macro_error::abort!(attrs_span, format!("{}", e)),
}