aboutsummaryrefslogtreecommitdiff
path: root/crates/server/tests/heavy_tests
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
committerAleksey Kladov <[email protected]>2018-09-02 14:36:03 +0100
commite98d8cd255ab5c2fee873a58af6c2c3ad561dab4 (patch)
tree04869b8fe93e724d8aa266177e48644051331ab9 /crates/server/tests/heavy_tests
parent1329dd4e287c137ec0a90abeec0272275b2b2c8d (diff)
nail down runnables
Diffstat (limited to 'crates/server/tests/heavy_tests')
-rw-r--r--crates/server/tests/heavy_tests/main.rs40
-rw-r--r--crates/server/tests/heavy_tests/support.rs13
2 files changed, 48 insertions, 5 deletions
diff --git a/crates/server/tests/heavy_tests/main.rs b/crates/server/tests/heavy_tests/main.rs
index 9c0196f22..0dc6074b2 100644
--- a/crates/server/tests/heavy_tests/main.rs
+++ b/crates/server/tests/heavy_tests/main.rs
@@ -14,10 +14,10 @@ use m::req::{Runnables, RunnablesParams, DidReloadWorkspace};
14 14
15use support::project; 15use support::project;
16 16
17const LOG: &'static str = "WARN"; 17const LOG: &'static str = "";
18 18
19#[test] 19#[test]
20fn test_runnables() { 20fn test_runnables_no_project() {
21 let server = project(r" 21 let server = project(r"
22//- lib.rs 22//- lib.rs
23#[test] 23#[test]
@@ -45,6 +45,42 @@ fn foo() {
45} 45}
46 46
47#[test] 47#[test]
48fn test_runnables_project() {
49 let server = project(r#"
50//- Cargo.toml
51[package]
52name = "foo"
53version = "0.0.0"
54
55//- src/lib.rs
56pub fn foo() {}
57
58//- tests/spam.rs
59#[test]
60fn test_eggs() {}
61"#);
62 server.wait_for_notification::<DidReloadWorkspace>();
63 server.request::<Runnables>(
64 RunnablesParams {
65 text_document: server.doc_id("tests/spam.rs"),
66 position: None,
67 },
68 r#"[
69 {
70 "args": [ "test", "--package", "foo", "--test", "spam", "--", "test_eggs", "--nocapture" ],
71 "bin": "cargo",
72 "env": { "RUST_BACKTRACE": "short" },
73 "label": "test test_eggs",
74 "range": {
75 "end": { "character": 17, "line": 1 },
76 "start": { "character": 0, "line": 0 }
77 }
78 }
79 ]"#
80 );
81}
82
83#[test]
48fn test_project_model() { 84fn test_project_model() {
49 let server = project(r#" 85 let server = project(r#"
50//- Cargo.toml 86//- Cargo.toml
diff --git a/crates/server/tests/heavy_tests/support.rs b/crates/server/tests/heavy_tests/support.rs
index 76cbd56ea..38a9e6c76 100644
--- a/crates/server/tests/heavy_tests/support.rs
+++ b/crates/server/tests/heavy_tests/support.rs
@@ -134,7 +134,7 @@ impl Server {
134 { 134 {
135 let expected = expected.replace("$PROJECT_ROOT$", &self.dir.path().display().to_string()); 135 let expected = expected.replace("$PROJECT_ROOT$", &self.dir.path().display().to_string());
136 let expected: Value = from_str(&expected).unwrap(); 136 let expected: Value = from_str(&expected).unwrap();
137 let actual = self.wait_for_notification(N::METHOD); 137 let actual = self.wait_for_notification::<N>();
138 assert_eq!( 138 assert_eq!(
139 expected, actual, 139 expected, actual,
140 "Expected:\n{}\n\ 140 "Expected:\n{}\n\
@@ -150,6 +150,11 @@ impl Server {
150 R::Params: Serialize, 150 R::Params: Serialize,
151 { 151 {
152 let r = RawRequest::new::<R>(id, &params); 152 let r = RawRequest::new::<R>(id, &params);
153 self.send_request_(r)
154 }
155 fn send_request_(&self, r: RawRequest) -> Value
156 {
157 let id = r.id;
153 self.sender.as_ref() 158 self.sender.as_ref()
154 .unwrap() 159 .unwrap()
155 .send(RawMessage::Request(r)); 160 .send(RawMessage::Request(r));
@@ -168,7 +173,10 @@ impl Server {
168 } 173 }
169 panic!("no response"); 174 panic!("no response");
170 } 175 }
171 fn wait_for_notification(&self, method: &str) -> Value { 176 pub fn wait_for_notification<N: Notification>(&self) -> Value {
177 self.wait_for_notification_(N::METHOD)
178 }
179 fn wait_for_notification_(&self, method: &str) -> Value {
172 let f = |msg: &RawMessage| match msg { 180 let f = |msg: &RawMessage| match msg {
173 RawMessage::Notification(n) if n.method == method => { 181 RawMessage::Notification(n) if n.method == method => {
174 Some(n.params.clone()) 182 Some(n.params.clone())
@@ -215,7 +223,6 @@ impl Drop for Server {
215 drop(msg); 223 drop(msg);
216 } 224 }
217 } 225 }
218 eprintln!("joining server");
219 self.server.take() 226 self.server.take()
220 .unwrap() 227 .unwrap()
221 .join().unwrap().unwrap(); 228 .join().unwrap().unwrap();