Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Translate client_lens_run
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Jan 20, 2019
1 parent d6e72ad commit 45d6692
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 77 deletions.
56 changes: 54 additions & 2 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::path::Path;

use futures::future::Future;
use lsp_types::{*, request::*, notification::*};
use serde_json::json;

use crate::support::basic_bin_manifest;
use crate::support::project_builder::project;
use crate::support::{basic_bin_manifest, fixtures_dir};
use crate::support::project_builder::{project, ProjectBuilder};

#[allow(dead_code)]
mod support;
Expand Down Expand Up @@ -970,3 +971,54 @@ fn client_format_utf16_range() {

rls.shutdown();
}

#[test]
fn client_lens_run() {
let p = ProjectBuilder::try_from_fixture(fixtures_dir().join("lens_run"))
.unwrap()
.build();
let root_path = p.root();
let mut rls = p.spawn_rls_async();

rls.request::<Initialize>(0, lsp_types::InitializeParams {
process_id: None,
root_uri: None,
root_path: Some(root_path.display().to_string()),
initialization_options: Some(json!({ "cmdRun": true})),
capabilities: Default::default(),
trace: None,
workspace_folders: None,
});

rls.wait_for_indexing();
assert!(rls.messages().iter().count() >= 7);

let lens = rls.request::<CodeLensRequest>(1, CodeLensParams {
text_document: TextDocumentIdentifier {
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
}
});

let expected = CodeLens {
command: Some(Command {
command: "rls.run".to_string(),
title: "Run test".to_string(),
arguments: Some(vec![
json!({
"args": [ "test", "--", "--nocapture", "test_foo" ],
"binary": "cargo",
"env": { "RUST_BACKTRACE": "short" }
})
]),
}),
data: None,
range: Range {
start: Position { line: 14, character: 3 },
end: Position { line: 14, character: 11 }
}
};

assert_eq!(lens, Some(vec![expected]));

rls.shutdown();
}
75 changes: 0 additions & 75 deletions tests/tests.rs

This file was deleted.

0 comments on commit 45d6692

Please sign in to comment.