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

Commit 65536f8

Browse files
committed
Split tooltip tests whether they depend on Racer fallback
1 parent 8753cb5 commit 65536f8

File tree

1 file changed

+77
-10
lines changed

1 file changed

+77
-10
lines changed

src/actions/hover.rs

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,11 @@ pub mod test {
11751175
impl TooltipTestHarness {
11761176
/// Creates a new `TooltipTestHarness`. The `project_dir` must contain
11771177
/// a valid rust project with a `Cargo.toml`.
1178-
pub fn new<O: Output>(project_dir: PathBuf, output: &O) -> TooltipTestHarness {
1178+
pub fn new<O: Output>(
1179+
project_dir: PathBuf,
1180+
output: &O,
1181+
racer_fallback_completion: bool,
1182+
) -> TooltipTestHarness {
11791183
use env_logger;
11801184
let _ = env_logger::try_init();
11811185

@@ -1194,6 +1198,7 @@ pub mod test {
11941198

11951199
let temp_dir = tempfile::tempdir().unwrap().into_path();
11961200
config.target_dir = config::Inferrable::Specified(Some(temp_dir.clone()));
1201+
config.racer_completion = racer_fallback_completion;
11971202

11981203
let config = Arc::new(Mutex::new(config));
11991204
let analysis = Arc::new(analysis::AnalysisHost::new(analysis::Target::Debug));
@@ -2082,7 +2087,6 @@ pub mod test {
20822087
Test::new("test_tooltip_01.rs", 68, 11),
20832088
Test::new("test_tooltip_01.rs", 68, 26),
20842089
Test::new("test_tooltip_01.rs", 75, 10),
2085-
Test::new("test_tooltip_01.rs", 80, 11),
20862090
Test::new("test_tooltip_01.rs", 85, 14),
20872091
Test::new("test_tooltip_01.rs", 85, 50),
20882092
Test::new("test_tooltip_01.rs", 85, 54),
@@ -2091,7 +2095,6 @@ pub mod test {
20912095
Test::new("test_tooltip_01.rs", 87, 20),
20922096
Test::new("test_tooltip_01.rs", 88, 18),
20932097
Test::new("test_tooltip_01.rs", 93, 11),
2094-
Test::new("test_tooltip_01.rs", 93, 18),
20952098
Test::new("test_tooltip_01.rs", 95, 25),
20962099
Test::new("test_tooltip_01.rs", 109, 21),
20972100
Test::new("test_tooltip_01.rs", 113, 21),
@@ -2100,7 +2103,38 @@ pub mod test {
21002103
Test::new("test_tooltip_mod_use.rs", 12, 14),
21012104
Test::new("test_tooltip_mod_use.rs", 12, 25),
21022105
Test::new("test_tooltip_mod_use.rs", 13, 28),
2103-
Test::new("test_tooltip_mod_use_external.rs", 11, 7),
2106+
];
2107+
2108+
let out = LineOutput::default();
2109+
let proj_dir = FIXTURES_DIR.join("hover");
2110+
2111+
let save_dir_guard = tempfile::tempdir().unwrap();
2112+
let save_dir = save_dir_guard.path().to_owned();
2113+
let load_dir = proj_dir.join("save_data");
2114+
2115+
let harness = TooltipTestHarness::new(proj_dir, &out, false);
2116+
2117+
out.reset();
2118+
2119+
let failures = harness.run_tests(&tests, load_dir, save_dir)?;
2120+
2121+
if failures.is_empty() {
2122+
Ok(())
2123+
} else {
2124+
eprintln!("{}\n\n", out.reset().join("\n"));
2125+
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
2126+
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
2127+
}
2128+
}
2129+
2130+
#[test]
2131+
fn test_tooltip_racer() -> Result<(), Box<dyn std::error::Error>> {
2132+
let _ = env_logger::try_init();
2133+
use self::test::{LineOutput, Test, TooltipTestHarness};
2134+
2135+
let tests = vec![
2136+
Test::new("test_tooltip_01.rs", 80, 11),
2137+
Test::new("test_tooltip_01.rs", 93, 18),
21042138
Test::new("test_tooltip_mod_use_external.rs", 11, 7),
21052139
Test::new("test_tooltip_mod_use_external.rs", 12, 7),
21062140
Test::new("test_tooltip_mod_use_external.rs", 12, 12),
@@ -2113,7 +2147,7 @@ pub mod test {
21132147
let save_dir = save_dir_guard.path().to_owned();
21142148
let load_dir = proj_dir.join("save_data");
21152149

2116-
let harness = TooltipTestHarness::new(proj_dir, &out);
2150+
let harness = TooltipTestHarness::new(proj_dir, &out, true);
21172151

21182152
out.reset();
21192153

@@ -2138,10 +2172,6 @@ pub mod test {
21382172
use self::test::{LineOutput, Test, TooltipTestHarness};
21392173

21402174
let tests = vec![
2141-
// these test std stuff
2142-
Test::new("test_tooltip_mod_use_external.rs", 14, 12),
2143-
Test::new("test_tooltip_mod_use_external.rs", 15, 12),
2144-
21452175
Test::new("test_tooltip_std.rs", 18, 15),
21462176
Test::new("test_tooltip_std.rs", 18, 27),
21472177
Test::new("test_tooltip_std.rs", 19, 7),
@@ -2164,7 +2194,44 @@ pub mod test {
21642194
let save_dir = save_dir_guard.path().to_owned();
21652195
let load_dir = proj_dir.join("save_data");
21662196

2167-
let harness = TooltipTestHarness::new(proj_dir, &out);
2197+
let harness = TooltipTestHarness::new(proj_dir, &out, false);
2198+
2199+
out.reset();
2200+
2201+
let failures = harness.run_tests(&tests, load_dir, save_dir)?;
2202+
2203+
if failures.is_empty() {
2204+
Ok(())
2205+
} else {
2206+
eprintln!("{}\n\n", out.reset().join("\n"));
2207+
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
2208+
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
2209+
}
2210+
}
2211+
2212+
/// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
2213+
/// It is enabled on CI.
2214+
/// Run with `cargo test test_tooltip_std -- --ignored`
2215+
#[test]
2216+
#[ignore]
2217+
fn test_tooltip_std_racer() -> Result<(), Box<dyn std::error::Error>> {
2218+
let _ = env_logger::try_init();
2219+
use self::test::{LineOutput, Test, TooltipTestHarness};
2220+
2221+
let tests = vec![
2222+
// these test std stuff
2223+
Test::new("test_tooltip_mod_use_external.rs", 14, 12),
2224+
Test::new("test_tooltip_mod_use_external.rs", 15, 12),
2225+
];
2226+
2227+
let out = LineOutput::default();
2228+
let proj_dir = FIXTURES_DIR.join("hover");
2229+
2230+
let save_dir_guard = tempfile::tempdir().unwrap();
2231+
let save_dir = save_dir_guard.path().to_owned();
2232+
let load_dir = proj_dir.join("save_data");
2233+
2234+
let harness = TooltipTestHarness::new(proj_dir, &out, true);
21682235

21692236
out.reset();
21702237

0 commit comments

Comments
 (0)