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

Split test_tooltip_mod tests #1195

Closed
Xanewok opened this issue Dec 17, 2018 · 1 comment
Closed

Split test_tooltip_mod tests #1195

Xanewok opened this issue Dec 17, 2018 · 1 comment

Comments

@Xanewok
Copy link
Member

Xanewok commented Dec 17, 2018

#1151 (comment)

Currently we have test_tooltip and test_tooltip_std which test if the hover request response matches what we expect - most often it's the type of hovered symbol.

rls/src/actions/hover.rs

Lines 2054 to 2193 in 6844569

#[test]
fn test_tooltip() -> Result<(), Box<dyn std::error::Error>> {
let _ = env_logger::try_init();
use self::test::{LineOutput, Test, TooltipTestHarness};
use std::env;
let tests = vec![
Test::new("test_tooltip_01.rs", 13, 11),
Test::new("test_tooltip_01.rs", 15, 7),
Test::new("test_tooltip_01.rs", 17, 7),
Test::new("test_tooltip_01.rs", 21, 13),
Test::new("test_tooltip_01.rs", 23, 9),
Test::new("test_tooltip_01.rs", 23, 16),
Test::new("test_tooltip_01.rs", 25, 8),
Test::new("test_tooltip_01.rs", 27, 8),
Test::new("test_tooltip_01.rs", 27, 8),
Test::new("test_tooltip_01.rs", 30, 11),
Test::new("test_tooltip_01.rs", 32, 10),
Test::new("test_tooltip_01.rs", 32, 19),
Test::new("test_tooltip_01.rs", 32, 26),
Test::new("test_tooltip_01.rs", 32, 35),
Test::new("test_tooltip_01.rs", 32, 49),
Test::new("test_tooltip_01.rs", 33, 11),
Test::new("test_tooltip_01.rs", 34, 16),
Test::new("test_tooltip_01.rs", 34, 23),
Test::new("test_tooltip_01.rs", 35, 16),
Test::new("test_tooltip_01.rs", 35, 23),
Test::new("test_tooltip_01.rs", 36, 16),
Test::new("test_tooltip_01.rs", 36, 23),
Test::new("test_tooltip_01.rs", 42, 15),
Test::new("test_tooltip_01.rs", 56, 6),
Test::new("test_tooltip_01.rs", 66, 6),
Test::new("test_tooltip_01.rs", 67, 30),
Test::new("test_tooltip_01.rs", 68, 11),
Test::new("test_tooltip_01.rs", 68, 26),
Test::new("test_tooltip_01.rs", 75, 10),
Test::new("test_tooltip_01.rs", 80, 11),
Test::new("test_tooltip_01.rs", 85, 14),
Test::new("test_tooltip_01.rs", 85, 50),
Test::new("test_tooltip_01.rs", 85, 54),
Test::new("test_tooltip_01.rs", 86, 7),
Test::new("test_tooltip_01.rs", 86, 10),
Test::new("test_tooltip_01.rs", 87, 20),
Test::new("test_tooltip_01.rs", 88, 18),
Test::new("test_tooltip_01.rs", 93, 11),
Test::new("test_tooltip_01.rs", 93, 18),
Test::new("test_tooltip_01.rs", 95, 25),
Test::new("test_tooltip_01.rs", 109, 21),
Test::new("test_tooltip_01.rs", 113, 21),
Test::new("test_tooltip_mod.rs", 22, 14),
Test::new("test_tooltip_mod_use.rs", 11, 14),
Test::new("test_tooltip_mod_use.rs", 12, 14),
Test::new("test_tooltip_mod_use.rs", 12, 25),
Test::new("test_tooltip_mod_use.rs", 13, 28),
Test::new("test_tooltip_mod_use_external.rs", 11, 7),
Test::new("test_tooltip_mod_use_external.rs", 11, 7),
Test::new("test_tooltip_mod_use_external.rs", 12, 7),
Test::new("test_tooltip_mod_use_external.rs", 12, 12),
];
let cwd = env::current_dir()?;
let out = LineOutput::default();
let proj_dir = cwd.join("test_data").join("hover");
let save_dir = cwd
.join("target")
.join("tests")
.join("hover")
.join("save_data");
let load_dir = proj_dir.join("save_data");
let harness = TooltipTestHarness::new(proj_dir, &out);
out.reset();
let failures = harness.run_tests(&tests, load_dir, save_dir)?;
if failures.is_empty() {
Ok(())
} else {
eprintln!("{}\n\n", out.reset().join("\n"));
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
}
}
/// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
/// It is enabled on CI.
/// Run with `cargo test test_tooltip_std -- --ignored`
#[test]
#[ignore]
fn test_tooltip_std() -> Result<(), Box<dyn std::error::Error>> {
let _ = env_logger::try_init();
use self::test::{LineOutput, Test, TooltipTestHarness};
use std::env;
let tests = vec![
// these test std stuff
Test::new("test_tooltip_mod_use_external.rs", 14, 12),
Test::new("test_tooltip_mod_use_external.rs", 15, 12),
Test::new("test_tooltip_std.rs", 18, 15),
Test::new("test_tooltip_std.rs", 18, 27),
Test::new("test_tooltip_std.rs", 19, 7),
Test::new("test_tooltip_std.rs", 19, 12),
Test::new("test_tooltip_std.rs", 20, 12),
Test::new("test_tooltip_std.rs", 20, 20),
Test::new("test_tooltip_std.rs", 21, 25),
Test::new("test_tooltip_std.rs", 22, 33),
Test::new("test_tooltip_std.rs", 23, 11),
Test::new("test_tooltip_std.rs", 23, 18),
Test::new("test_tooltip_std.rs", 24, 24),
Test::new("test_tooltip_std.rs", 25, 17),
Test::new("test_tooltip_std.rs", 25, 25),
];
let cwd = env::current_dir()?;
let out = LineOutput::default();
let proj_dir = cwd.join("test_data").join("hover");
let save_dir = cwd
.join("target")
.join("tests")
.join("hover")
.join("save_data");
let load_dir = proj_dir.join("save_data");
let harness = TooltipTestHarness::new(proj_dir, &out);
out.reset();
let failures = harness.run_tests(&tests, load_dir, save_dir)?;
if failures.is_empty() {
Ok(())
} else {
eprintln!("{}\n\n", out.reset().join("\n"));
eprintln!("Failures (\x1b[91mexpected\x1b[92mactual\x1b[0m): {:#?}\n\n", failures);
Err(format!("{} of {} tooltip tests failed", failures.len(), tests.len()).into())
}
}
}

Right now, when actual index data from rustc build can't be queried, we fall back to Racer and ask it to show us definition for a given span, this fallback is configured by racer_completion option (now defaults to true).
It'd be good to split these

rls/src/actions/hover.rs

Lines 2151 to 2152 in 6844569

Test::new("test_tooltip_mod_use_external.rs", 14, 12),
Test::new("test_tooltip_mod_use_external.rs", 15, 12),

into test_tooltip_racer_fallback and enhance TooltipTestHarness to be able to receive custom configuration when created:
let mut config = config::Config::default();

Now, except for newly-separated test_tooltip_racer_fallback, every other tooltip test should have racer_completion explicitly disabled so we don't have to guess why the data is not as expected.

@Xanewok
Copy link
Member Author

Xanewok commented Dec 17, 2018

As per @alexheretic's #1151 (comment), it seems that

Test::new("test_tooltip_01.rs", 80, 11),

Test::new("test_tooltip_01.rs", 93, 18),

rls/src/actions/hover.rs

Lines 2108 to 2111 in 6844569

Test::new("test_tooltip_mod_use_external.rs", 11, 7),
Test::new("test_tooltip_mod_use_external.rs", 11, 7),
Test::new("test_tooltip_mod_use_external.rs", 12, 7),
Test::new("test_tooltip_mod_use_external.rs", 12, 12),

from test_tooltip also need to be separated out

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant