2018-09-02 06:46:15 -05:00
|
|
|
#[macro_use]
|
2018-09-01 12:21:11 -05:00
|
|
|
extern crate crossbeam_channel;
|
2018-10-15 16:44:23 -05:00
|
|
|
extern crate flexi_logger;
|
|
|
|
extern crate gen_lsp_server;
|
2018-09-01 12:21:11 -05:00
|
|
|
extern crate languageserver_types;
|
2018-10-15 16:44:23 -05:00
|
|
|
extern crate ra_lsp_server;
|
2018-09-01 12:21:11 -05:00
|
|
|
extern crate serde;
|
|
|
|
extern crate serde_json;
|
2018-10-15 16:44:23 -05:00
|
|
|
extern crate tempdir;
|
2018-09-01 12:21:11 -05:00
|
|
|
|
|
|
|
mod support;
|
|
|
|
|
2018-09-16 04:54:24 -05:00
|
|
|
use ra_lsp_server::req::{Runnables, RunnablesParams};
|
2018-09-01 12:21:11 -05:00
|
|
|
|
2018-10-15 12:15:53 -05:00
|
|
|
use crate::support::project;
|
2018-09-01 12:21:11 -05:00
|
|
|
|
2018-09-02 08:36:03 -05:00
|
|
|
const LOG: &'static str = "";
|
2018-09-02 06:46:15 -05:00
|
|
|
|
2018-09-01 12:21:11 -05:00
|
|
|
#[test]
|
2018-09-02 08:36:03 -05:00
|
|
|
fn test_runnables_no_project() {
|
2018-10-15 16:44:23 -05:00
|
|
|
let server = project(
|
|
|
|
r"
|
2018-09-01 12:21:11 -05:00
|
|
|
//- lib.rs
|
|
|
|
#[test]
|
|
|
|
fn foo() {
|
|
|
|
}
|
2018-10-15 16:44:23 -05:00
|
|
|
",
|
|
|
|
);
|
2018-09-01 12:21:11 -05:00
|
|
|
server.request::<Runnables>(
|
|
|
|
RunnablesParams {
|
|
|
|
text_document: server.doc_id("lib.rs"),
|
|
|
|
position: None,
|
|
|
|
},
|
|
|
|
r#"[
|
|
|
|
{
|
|
|
|
"args": [ "test", "--", "foo", "--nocapture" ],
|
|
|
|
"bin": "cargo",
|
|
|
|
"env": { "RUST_BACKTRACE": "short" },
|
|
|
|
"label": "test foo",
|
|
|
|
"range": {
|
|
|
|
"end": { "character": 1, "line": 2 },
|
|
|
|
"start": { "character": 0, "line": 0 }
|
|
|
|
}
|
2018-10-25 05:42:53 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": [
|
|
|
|
"check",
|
|
|
|
"--all"
|
|
|
|
],
|
|
|
|
"bin": "cargo",
|
|
|
|
"env": {},
|
|
|
|
"label": "cargo check --all",
|
|
|
|
"range": {
|
|
|
|
"end": {
|
|
|
|
"character": 0,
|
|
|
|
"line": 0
|
|
|
|
},
|
|
|
|
"start": {
|
|
|
|
"character": 0,
|
|
|
|
"line": 0
|
|
|
|
}
|
|
|
|
}
|
2018-09-01 12:21:11 -05:00
|
|
|
}
|
2018-10-15 16:44:23 -05:00
|
|
|
]"#,
|
2018-09-01 12:21:11 -05:00
|
|
|
);
|
|
|
|
}
|
2018-09-02 06:46:15 -05:00
|
|
|
|
2018-09-02 08:36:03 -05:00
|
|
|
#[test]
|
|
|
|
fn test_runnables_project() {
|
2018-10-15 16:44:23 -05:00
|
|
|
let server = project(
|
|
|
|
r#"
|
2018-09-02 08:36:03 -05:00
|
|
|
//- Cargo.toml
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
|
|
|
|
//- src/lib.rs
|
|
|
|
pub fn foo() {}
|
|
|
|
|
|
|
|
//- tests/spam.rs
|
|
|
|
#[test]
|
|
|
|
fn test_eggs() {}
|
2018-10-15 16:44:23 -05:00
|
|
|
"#,
|
|
|
|
);
|
2018-09-03 15:32:42 -05:00
|
|
|
server.wait_for_feedback("workspace loaded");
|
2018-09-02 08:36:03 -05:00
|
|
|
server.request::<Runnables>(
|
|
|
|
RunnablesParams {
|
|
|
|
text_document: server.doc_id("tests/spam.rs"),
|
|
|
|
position: None,
|
|
|
|
},
|
|
|
|
r#"[
|
|
|
|
{
|
|
|
|
"args": [ "test", "--package", "foo", "--test", "spam", "--", "test_eggs", "--nocapture" ],
|
|
|
|
"bin": "cargo",
|
|
|
|
"env": { "RUST_BACKTRACE": "short" },
|
|
|
|
"label": "test test_eggs",
|
|
|
|
"range": {
|
|
|
|
"end": { "character": 17, "line": 1 },
|
|
|
|
"start": { "character": 0, "line": 0 }
|
|
|
|
}
|
2018-10-25 05:42:53 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": [
|
|
|
|
"check",
|
|
|
|
"--package",
|
|
|
|
"foo",
|
|
|
|
"--test",
|
|
|
|
"spam"
|
|
|
|
],
|
|
|
|
"bin": "cargo",
|
|
|
|
"env": {},
|
|
|
|
"label": "cargo check -p foo",
|
|
|
|
"range": {
|
|
|
|
"end": {
|
|
|
|
"character": 0,
|
|
|
|
"line": 0
|
|
|
|
},
|
|
|
|
"start": {
|
|
|
|
"character": 0,
|
|
|
|
"line": 0
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 08:36:03 -05:00
|
|
|
}
|
|
|
|
]"#
|
|
|
|
);
|
|
|
|
}
|