Skip to content

Commit

Permalink
Add integration testing module
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Mar 10, 2020
1 parent a446ecb commit 69586dc
Show file tree
Hide file tree
Showing 8 changed files with 467 additions and 5 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
]

[dependencies]
aovec = "1.1"
byteorder = "1.3"
bytes = "0.5"
chashmap = "2.2"
Expand Down
10 changes: 5 additions & 5 deletions crates/jsonrpc_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn jsonrpc_server(_attr: TokenStream, item: TokenStream) -> TokenStream {
#impl_

impl #generics crate::jsonrpc::RequestHandler for #self_ty {
#[boxed]
#[futures_boxed::boxed]
async fn handle_request(&self, request: crate::jsonrpc::Request) -> crate::jsonrpc::Response {
use crate::jsonrpc::*;

Expand All @@ -79,7 +79,7 @@ pub fn jsonrpc_server(_attr: TokenStream, item: TokenStream) -> TokenStream {
}
}

#[boxed]
#[futures_boxed::boxed]
async fn handle_notification(&self, notification: crate::jsonrpc::Notification) {
match notification.method.as_str() {
#(#notifications),*,
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn jsonrpc_client(attr: TokenStream, item: TokenStream) -> TokenStream {

impl crate::jsonrpc::ResponseHandler for #struct_ident
{
#[boxed]
#[futures_boxed::boxed]
async fn handle(&self, response: crate::jsonrpc::Response) -> () {
self.client.handle(response).await
}
Expand Down Expand Up @@ -189,14 +189,14 @@ fn generate_client_stubs(items: &Vec<TraitItem>) -> Vec<TokenStream2> {

let stub = match meta.kind {
MethodKind::Request => quote!(
#[boxed]
#[futures_boxed::boxed]
#sig {
let result = self.client.send_request(#name.to_owned(), #param).await?;
serde_json::from_value(result).map_err(|_| crate::jsonrpc::Error::deserialize_error())
}
),
MethodKind::Notification => quote!(
#[boxed]
#[futures_boxed::boxed]
#sig {
self.client.send_notification(#name.to_owned(), #param).await
}
Expand Down
1 change: 1 addition & 0 deletions src/jsonrpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use futures::{channel::mpsc, prelude::*};
use log::error;
use std::sync::Arc;

#[derive(Debug)]
pub struct MessageHandler<S, C> {
pub server: Arc<S>,
pub client: Arc<C>,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pub mod link;
pub mod protocol;
pub mod server;
pub mod syntax;
pub mod test;
pub mod tex;
pub mod workspace;
38 changes: 38 additions & 0 deletions src/test/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use crate::{jsonrpc::client::Result, protocol::*};
use futures_boxed::boxed;
use jsonrpc_derive::{jsonrpc_client, jsonrpc_method};

#[jsonrpc_client(TestLatexLspClient)]
pub trait TestLspClient {
#[jsonrpc_method("initialize", kind = "request")]
#[boxed]
async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult>;

#[jsonrpc_method("initialized", kind = "notification")]
#[boxed]
async fn initialized(&self, params: InitializedParams);

#[jsonrpc_method("shutdown", kind = "request")]
#[boxed]
async fn shutdown(&self, params: ()) -> Result<()>;

#[jsonrpc_method("exit", kind = "notification")]
#[boxed]
async fn exit(&self, params: ());

#[jsonrpc_method("textDocument/didOpen", kind = "notification")]
#[boxed]
async fn did_open(&self, params: DidOpenTextDocumentParams);

#[jsonrpc_method("textDocument/didChange", kind = "notification")]
#[boxed]
async fn did_change(&self, params: DidChangeTextDocumentParams);

#[jsonrpc_method("workspace/didChangeConfiguration", kind = "notification")]
#[boxed]
async fn did_change_configuration(&self, params: DidChangeConfigurationParams);

#[jsonrpc_method("textDocument/documentLink", kind = "request")]
#[boxed]
async fn document_link(&self, params: DocumentLinkParams) -> Result<Vec<DocumentLink>>;
}
Loading

0 comments on commit 69586dc

Please sign in to comment.