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

Commit ae0cdb3

Browse files
committed
Output expected/actual string diffs for tooltip test failures
1 parent 19c311d commit ae0cdb3

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ toml = "0.4"
4949
# for more information.
5050
rustc-workspace-hack = "1.0.0"
5151

52+
[dev-dependencies]
53+
difference = "2"
54+
5255
[build-dependencies]
5356
rustc_tools_util = { git = "https://github.com/rust-lang/rust-clippy", rev = "a3c77f6ad1c1c185e561e9cd7fdec7db569169d1" }
5457

src/actions/hover.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ pub mod test {
991991
use std::path::PathBuf;
992992
use std::process;
993993
use std::sync::{Arc, Mutex};
994+
use std::fmt;
994995

995996
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
996997
pub struct Test {
@@ -1106,7 +1107,7 @@ pub mod test {
11061107
}
11071108
}
11081109

1109-
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
1110+
#[derive(PartialEq, Eq)]
11101111
pub struct TestFailure {
11111112
/// The test case, indicating file, line, and column
11121113
pub test: Test,
@@ -1123,6 +1124,21 @@ pub mod test {
11231124
pub actual_data: Result<Result<Vec<MarkedString>, String>, ()>,
11241125
}
11251126

1127+
impl fmt::Debug for TestFailure {
1128+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1129+
fmt.debug_struct("TestFailure")
1130+
.field("test", &self.test)
1131+
.field("expect_file", &self.expect_file)
1132+
.field("actual_file", &self.actual_file)
1133+
.finish()?;
1134+
1135+
let expected = format!("{:#?}", self.expect_data);
1136+
let actual = format!("{:#?}", self.actual_data);
1137+
write!(fmt, "-diff: {}", difference::Changeset::new(&expected, &actual, ""))
1138+
}
1139+
}
1140+
1141+
11261142
#[derive(Clone, Default)]
11271143
pub struct LineOutput {
11281144
req_id: Arc<Mutex<u64>>,
@@ -2117,7 +2133,7 @@ pub mod test {
21172133
Ok(())
21182134
} else {
21192135
eprintln!("{}\n\n", out.reset().join("\n"));
2120-
eprintln!("{:#?}\n\n", failures);
2136+
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
21212137
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
21222138
}
21232139
}
@@ -2172,7 +2188,7 @@ pub mod test {
21722188
Ok(())
21732189
} else {
21742190
eprintln!("{}\n\n", out.reset().join("\n"));
2175-
eprintln!("{:#?}\n\n", failures);
2191+
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
21762192
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
21772193
}
21782194
}

src/actions/notifications.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::Span;
1515
use log::{debug, trace, warn};
1616
use rls_vfs::{Change, VfsSpan};
1717
use serde::Deserialize;
18-
use serde_json;
1918
use std::sync::atomic::Ordering;
2019

2120
use crate::build::*;

0 commit comments

Comments
 (0)