diff --git a/server/src/tests/kvengine.rs b/server/src/tests/kvengine.rs index 4b300c7f..8741eca3 100644 --- a/server/src/tests/kvengine.rs +++ b/server/src/tests/kvengine.rs @@ -215,7 +215,7 @@ mod __private { let res_should_be = "#2\n*1\n#2\n&1\n:1\n1\n".to_owned().into_bytes(); let mut response = vec![0; res_should_be.len()]; stream.read_exact(&mut response).await.unwrap(); - assert_eq!(response, res_should_be, "{}: With one arg(s)", __func__!()); + assert_eq!(response, res_should_be, "With one arg(s)"); let query = terrapipe::proc_query("EXISTS x y z"); stream.write_all(&query).await.unwrap(); let res_should_be = "#2\n*1\n#2\n&1\n:1\n3\n".to_owned().into_bytes(); diff --git a/server/src/tests/mod.rs b/server/src/tests/mod.rs index 15992871..43146b44 100644 --- a/server/src/tests/mod.rs +++ b/server/src/tests/mod.rs @@ -24,11 +24,9 @@ use crate::config::SnapshotConfig; use crate::coredb::CoreDB; use crate::dbnet; -use crate::protocol::responses::fresp; use crate::BGSave; -use libtdb::terrapipe; -use std::net::{SocketAddr}; -use tokio::net::{TcpListener, TcpStream}; +use std::net::SocketAddr; +use tokio::net::TcpListener; mod kvengine; /// The function macro returns the name of a function diff --git a/tdb-macros/src/lib.rs b/tdb-macros/src/lib.rs index b5d8724f..ec9cd315 100644 --- a/tdb-macros/src/lib.rs +++ b/tdb-macros/src/lib.rs @@ -28,8 +28,10 @@ use rand::*; use std::collections::HashSet; use syn::{self}; -// TODO(@ohsayan): Write docs and also make this use the tokio runtime - +/// This parses a function within a `dbtest` module +/// +/// This accepts an `async` function and returns a non-`async` version of it - by +/// making the body of the function use the `tokio` runtime fn parse_dbtest(mut input: syn::ItemFn, rand: u16) -> Result { let sig = &mut input.sig; let fname = sig.ident.to_string(); @@ -45,9 +47,11 @@ fn parse_dbtest(mut input: syn::ItemFn, rand: u16) -> Result Result TokenStream { for attr in &input.attrs { if attr.path.is_ident("test") { @@ -90,6 +95,8 @@ fn parse_test_sig(input: syn::ItemFn, rand: u16) -> TokenStream { parse_dbtest(input, rand).unwrap_or_else(|e| e.to_compile_error().into()) } +/// This function accepts an entire module which comprises of `dbtest` functions. +/// It takes each function in turn, and generates `#[test]`able functions for them fn parse_test_module(args: TokenStream, item: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(item as syn::ItemMod); let content = match input.content { @@ -214,6 +221,28 @@ fn parse_string(int: syn::Lit, span: Span, field: &str) -> Result TokenStream { parse_test_module(args, item) }