Remove unneeded syn parse

This commit is contained in:
2022-06-16 14:15:50 +00:00
committed by GitHub
parent 8ec5c66ee5
commit d1e1296181
3 changed files with 5 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ A pixiv downloader written in Rust.
- [ ] Add support for multiple threads download.
- [ ] Batch download.
- [ ] Fanbox support.
### TODO - CVE
- [ ] Remove parse_duration dependency which used in unittest.
## Rust features flags
### all

View File

@@ -8,7 +8,6 @@ use syn::parse_macro_input;
use syn::Ident;
use syn::ItemFn;
use syn::LitInt;
use syn::LitStr;
#[proc_macro]
pub fn define_struct_reader_fn(item: TokenStream) -> TokenStream {
@@ -92,8 +91,7 @@ pub fn async_timeout_test(attr: TokenStream, item: TokenStream) -> TokenStream {
sig,
block,
} = parse_macro_input!(item as ItemFn);
let meta = parse_macro_input!(attr as LitStr);
let dura = parse_duration::parse(meta.value().as_str()).unwrap();
let dura = parse_duration::parse(attr.to_string().as_str()).unwrap();
let secs = LitInt::new(format!("{}", dura.as_secs()).as_str(), sig.ident.span());
let nanos = LitInt::new(
format!("{}", dura.subsec_nanos()).as_str(),

View File

@@ -679,7 +679,7 @@ impl<T: Write + Seek + Send + Sync + ClearFile + GetTargetFileName> Drop for Dow
}
}
#[proc_macros::async_timeout_test("100s")]
#[proc_macros::async_timeout_test(120s)]
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_downloader() {
let p = Path::new("./test");
@@ -721,7 +721,7 @@ async fn test_downloader() {
}
}
#[proc_macros::async_timeout_test("60s")]
#[proc_macros::async_timeout_test(120s)]
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_failed_downloader() {
let p = Path::new("./test");
@@ -758,7 +758,7 @@ async fn test_failed_downloader() {
}
}
#[proc_macros::async_timeout_test("60s")]
#[proc_macros::async_timeout_test(120s)]
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_downloader_dropped() {
let p = Path::new("./test");