diff --git a/Cargo.lock b/Cargo.lock index 19618a80159..8459057056b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1168,6 +1168,7 @@ dependencies = [ "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 81344c9db99..e75db67dabf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ rustc-workspace-hack = "1.0.0" [dev-dependencies] difference = "2" +tempfile = "3" [build-dependencies] rustc_tools_util = { git = "https://github.com/rust-lang/rust-clippy", rev = "a3c77f6ad1c1c185e561e9cd7fdec7db569169d1" } diff --git a/src/actions/diagnostics.rs b/src/actions/diagnostics.rs index 76d28e120d2..8e5c82903a4 100644 --- a/src/actions/diagnostics.rs +++ b/src/actions/diagnostics.rs @@ -344,11 +344,16 @@ impl IsWithin for Range { /// Tests for formatted messages from the compilers json output /// run cargo with `--message-format=json` to generate the json for new tests and add .json -/// message files to '../../test_data/compiler_message/' +/// message files to '$(crate::test::FIXTURES_DIR)/compiler_message/' #[cfg(test)] mod diagnostic_message_test { use super::*; use languageserver_types::Position; + pub(super) use crate::test::FIXTURES_DIR; + + pub(super) fn read_fixture(path: impl AsRef) -> String { + std::fs::read_to_string(FIXTURES_DIR.join(path.as_ref())).unwrap() + } pub(super) fn parse_compiler_message( compiler_message: &str, @@ -413,7 +418,7 @@ mod diagnostic_message_test { #[test] fn message_use_after_move() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/use-after-move.json"), + &read_fixture("compiler_message/use-after-move.json"), true, ); @@ -443,7 +448,7 @@ mod diagnostic_message_test { #[test] fn message_type_annotations_needed() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/type-annotations-needed.json"), + &read_fixture("compiler_message/type-annotations-needed.json"), true, ).to_messages(); assert_eq!( @@ -460,7 +465,7 @@ mod diagnostic_message_test { // Check if we don't emit related information if it's not supported and // if secondary spans are emitted as separate diagnostics let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/type-annotations-needed.json"), + &read_fixture("compiler_message/type-annotations-needed.json"), false, ); @@ -486,7 +491,7 @@ mod diagnostic_message_test { #[test] fn message_mismatched_types() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/mismatched-types.json"), + &read_fixture("compiler_message/mismatched-types.json"), true, ).to_messages(); assert_eq!( @@ -513,7 +518,7 @@ mod diagnostic_message_test { #[test] fn message_not_mutable() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/not-mut.json"), + &read_fixture("compiler_message/not-mut.json"), true, ).to_messages(); assert_eq!( @@ -542,7 +547,7 @@ mod diagnostic_message_test { #[test] fn message_consider_borrowing() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/consider-borrowing.json"), + &read_fixture("compiler_message/consider-borrowing.json"), true, ).to_messages(); assert_eq!( @@ -573,7 +578,7 @@ help: consider borrowing here: `&string`"#, #[test] fn message_move_out_of_borrow() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/move-out-of-borrow.json"), + &read_fixture("compiler_message/move-out-of-borrow.json"), true, ).to_messages(); assert_eq!( @@ -596,7 +601,7 @@ help: consider borrowing here: `&string`"#, #[test] fn message_unused_use() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/unused-use.json"), + &read_fixture("compiler_message/unused-use.json"), true, ).to_messages(); @@ -616,7 +621,7 @@ help: consider borrowing here: `&string`"#, #[test] fn message_cannot_find_type() { let messages = parse_compiler_message( - include_str!("../../test_data/compiler_message/cannot-find-type.json"), + &read_fixture("compiler_message/cannot-find-type.json"), true, ).to_messages(); assert_eq!( @@ -634,7 +639,7 @@ help: consider borrowing here: `&string`"#, #[test] fn message_clippy_identity_op() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/clippy-identity-op.json"), + &read_fixture("compiler_message/clippy-identity-op.json"), true, ); @@ -674,7 +679,7 @@ help: consider borrowing here: `&string`"#, #[test] fn macro_error_no_trait() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/macro-error-no-trait.json"), + &read_fixture("compiler_message/macro-error-no-trait.json"), true, ); assert_eq!(diag.diagnostics.len(), 1, "{:#?}", diag.diagnostics); @@ -717,7 +722,7 @@ help: consider borrowing here: `&string`"#, #[test] fn macro_expected_token_nested_expansion() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/macro-expected-token.json"), + &read_fixture("compiler_message/macro-expected-token.json"), true, ); assert_eq!(diag.diagnostics.len(), 1, "{:#?}", diag.diagnostics); @@ -756,7 +761,7 @@ mod diagnostic_suggestion_test { #[test] fn suggest_use_when_cannot_find_type() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/cannot-find-type.json"), + &read_fixture("compiler_message/cannot-find-type.json"), true, ); @@ -787,7 +792,7 @@ mod diagnostic_suggestion_test { #[test] fn suggest_mut_when_not_mut() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/not-mut.json"), + &read_fixture("compiler_message/not-mut.json"), true, ); @@ -818,7 +823,7 @@ mod diagnostic_suggestion_test { #[test] fn suggest_clippy_const_static() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/clippy-const-static-lifetime.json"), + &read_fixture("compiler_message/clippy-const-static-lifetime.json"), true, ); @@ -846,7 +851,7 @@ mod diagnostic_suggestion_test { #[test] fn suggest_macro_error_no_trait() { let diag = parse_compiler_message( - include_str!("../../test_data/compiler_message/macro-error-no-trait.json"), + &read_fixture("compiler_message/macro-error-no-trait.json"), true, ); let diagnostics = diag.diagnostics.values().nth(0).unwrap(); diff --git a/src/actions/hover.rs b/src/actions/hover.rs index 31c172a8f3f..dde653e4c56 100644 --- a/src/actions/hover.rs +++ b/src/actions/hover.rs @@ -977,6 +977,7 @@ pub mod test { use crate::lsp_data::{ClientCapabilities, InitializationOptions}; use crate::lsp_data::{Position, TextDocumentIdentifier, TextDocumentPositionParams}; use crate::server::{Output, RequestId}; + use crate::test::FIXTURES_DIR; use rls_analysis as analysis; use serde_derive::{Deserialize, Serialize}; use serde_json as json; @@ -991,7 +992,7 @@ pub mod test { #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] pub struct Test { - /// Relative to the project _source_ dir (e.g. relative to test_data/hover/src) + /// Relative to the project _source_ dir (e.g. relative to FIXTURES_DIR/hover/src) pub file: String, /// One-based line number pub line: u64, @@ -1672,67 +1673,67 @@ pub mod test { #[test] fn test_extract_decl() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_decl.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_decl.rs"); let expected = "pub fn foo() -> Foo"; let row_start = Row::new_zero_indexed(10); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("function declaration") .join("\n"); assert_eq!(expected, actual); let expected = "pub struct Foo"; let row_start = Row::new_zero_indexed(15); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("struct declaration") .join("\n"); assert_eq!(expected, actual); let expected = "pub enum Bar"; let row_start = Row::new_zero_indexed(20); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("enum declaration") .join("\n"); assert_eq!(expected, actual); let expected = "pub struct NewType(pub u32, f32)"; let row_start = Row::new_zero_indexed(25); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("tuple declaration") .join("\n"); assert_eq!(expected, actual); let expected = "pub fn new() -> NewType"; let row_start = Row::new_zero_indexed(28); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("struct function declaration") .join("\n"); assert_eq!(expected, actual); let expected = "pub fn bar(&self, the_really_long_name_string: String, the_really_long_name_foo: Foo) -> Vec<(String, Foo)>"; let row_start = Row::new_zero_indexed(32); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("long struct method declaration with generics") .join("\n"); assert_eq!(expected, actual); let expected = "pub trait Baz where T: Copy"; let row_start = Row::new_zero_indexed(37); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("enum declaration") .join("\n"); assert_eq!(expected, actual); let expected = "fn make_copy(&self) -> Self"; let row_start = Row::new_zero_indexed(38); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("trait method declaration") .join("\n"); assert_eq!(expected, actual); let expected = "fn make_copy(&self) -> Self"; let row_start = Row::new_zero_indexed(42); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("trait method implementation") .join("\n"); assert_eq!(expected, actual); @@ -1745,7 +1746,7 @@ pub mod test { ", ); let row_start = Row::new_zero_indexed(47); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("trait declaration multiline") .join("\n"); assert_eq!(expected, actual); @@ -1759,7 +1760,7 @@ pub mod test { ", ); let row_start = Row::new_zero_indexed(53); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("function declaration multiline") .join("\n"); assert_eq!(expected, actual); @@ -1837,7 +1838,7 @@ pub mod test { #[test] fn test_extract_decl_multiline_empty_function() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_decl_multiline_empty_function.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_decl_multiline_empty_function.rs"); let expected = noindent( " @@ -1850,7 +1851,7 @@ pub mod test { ", ); let row_start = Row::new_zero_indexed(21); - let actual = extract_decl(&vfs, file, row_start) + let actual = extract_decl(&vfs, &file, row_start) .expect("the empty body should not be extracted") .join("\n"); assert_eq!(expected, actual); @@ -1859,7 +1860,7 @@ pub mod test { #[test] fn test_extract_docs_module_docs_with_attribute() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_module_docs_with_attribute.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_module_docs_with_attribute.rs"); let row_start = Row::new_zero_indexed(0); let actual = extract_docs(&vfs, &file, row_start) .expect(&format!("failed to extract docs: {:?}", file)) @@ -1883,7 +1884,7 @@ pub mod test { #[test] fn test_extract_docs_module_docs_no_copyright() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_module_docs_no_copyright.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_module_docs_no_copyright.rs"); let row_start = Row::new_zero_indexed(0); let actual = extract_docs(&vfs, &file, row_start) .expect(&format!("failed to extract docs: {:?}", file)) @@ -1907,7 +1908,7 @@ pub mod test { #[test] fn test_extract_docs_comment_block() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_comment_block.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_comment_block.rs"); let row_start = Row::new_zero_indexed(21); let actual = extract_docs(&vfs, &file, row_start) .expect(&format!("failed to extract docs: {:?}", file)) @@ -1931,7 +1932,7 @@ pub mod test { #[test] fn test_extract_docs_empty_line_before_decl() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_empty_line_before_decl.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_empty_line_before_decl.rs"); let row_start = Row::new_zero_indexed(18); let actual = extract_docs(&vfs, &file, row_start) .expect(&format!("failed to extract docs: {:?}", file)) @@ -1955,7 +1956,7 @@ pub mod test { #[test] fn test_extract_docs_module_docs() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_module_docs.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_module_docs.rs"); let row_start = Row::new_zero_indexed(0); let actual = extract_docs(&vfs, &file, row_start) @@ -1995,7 +1996,7 @@ pub mod test { #[test] fn test_extract_docs_attributes() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_attributes.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_attributes.rs"); let row_start = Row::new_zero_indexed(21); let actual = extract_docs(&vfs, &file, row_start) @@ -2039,7 +2040,7 @@ pub mod test { #[test] fn test_extract_docs_comment_first_line() { let vfs = Vfs::new(); - let file = Path::new("test_data/hover/src/test_extract_docs_comment_first_line.rs"); + let file = FIXTURES_DIR.join("hover/src/test_extract_docs_comment_first_line.rs"); let row_start = Row::new_zero_indexed(1); let actual = extract_docs(&vfs, &file, row_start) @@ -2113,7 +2114,7 @@ pub mod test { let cwd = env::current_dir()?; let out = LineOutput::default(); - let proj_dir = cwd.join("test_data").join("hover"); + let proj_dir = FIXTURES_DIR.join("hover"); let save_dir = cwd .join("target") .join("tests") @@ -2168,7 +2169,7 @@ pub mod test { let cwd = env::current_dir()?; let out = LineOutput::default(); - let proj_dir = cwd.join("test_data").join("hover"); + let proj_dir = FIXTURES_DIR.join("hover"); let save_dir = cwd .join("target") .join("tests") diff --git a/src/test/harness.rs b/src/test/harness.rs index fce6d9955aa..b446f60043d 100644 --- a/src/test/harness.rs +++ b/src/test/harness.rs @@ -13,7 +13,7 @@ use std::collections::HashMap; use std::env; use std::fs::File; -use std::io::{BufRead, BufReader}; +use std::io::{self, BufRead, BufReader}; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; @@ -26,6 +26,13 @@ use lazy_static::lazy_static; use rls_analysis::{AnalysisHost, Target}; use rls_vfs::Vfs; use serde_json; +use walkdir::WalkDir; + +lazy_static! { + static ref COUNTER: AtomicUsize = AtomicUsize::new(0); + static ref MANIFEST_DIR: &'static Path = Path::new(env!("CARGO_MANIFEST_DIR")); + pub static ref FIXTURES_DIR: PathBuf = MANIFEST_DIR.join("tests").join("fixtures"); +} crate struct Environment { crate config: Option, @@ -34,35 +41,19 @@ crate struct Environment { } impl Environment { - crate fn new(project_dir: &str) -> Self { - use std::sync::atomic::{AtomicUsize, Ordering}; - - lazy_static! { - static ref COUNTER: AtomicUsize = AtomicUsize::new(0); - } - + crate fn generate_from_fixture(fixture_dir: impl AsRef) -> Self { let _ = env_logger::try_init(); if env::var("RUSTC").is_err() { env::set_var("RUSTC", "rustc"); } - // Acquire the current directory, but this is changing when tests are - // running so we need to be sure to access it in a synchronized fashion. - let cur_dir = { - use crate::build::environment::{Environment, EnvironmentLock}; - let env = EnvironmentLock::get(); - let (guard, _other) = env.lock(); - let env = Environment::push_with_lock(&HashMap::new(), None, guard); - match env::var_os("RLS_TEST_WORKSPACE_DIR") { - Some(cur_dir) => cur_dir.into(), - None => env.get_old_cwd().to_path_buf(), - } - }; - let project_path = cur_dir.join("test_data").join(project_dir); + let fixture_dir = FIXTURES_DIR.join(fixture_dir.as_ref()); + let scratchpad_dir = build_scratchpad_from_fixture(fixture_dir) + .expect("Can't copy fixture files to scratchpad"); let target_dir = env::var("CARGO_TARGET_DIR") .map(|s| Path::new(&s).to_owned()) - .unwrap_or_else(|_| cur_dir.join("target")); + .unwrap_or_else(|_| MANIFEST_DIR.join("target")); let working_dir = target_dir .join("tests") @@ -72,7 +63,7 @@ impl Environment { config.target_dir = Inferrable::Specified(Some(working_dir.clone())); config.unstable_features = true; - let cache = Cache::new(project_path); + let cache = Cache::new(scratchpad_dir); Self { config: Some(config), @@ -120,6 +111,32 @@ impl Drop for Environment { } } +pub fn build_scratchpad_from_fixture(fixture_dir: impl AsRef) -> io::Result { + let fixture_dir = fixture_dir.as_ref(); + + let dirname = fixture_dir.file_name() + .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "No filename"))?; + + // FIXME: For now persist the path; ideally we should clean up after every test + let genroot = tempfile::tempdir()?.into_path().join(dirname); + // Recursively copy read-only fixture files to freshly generated scratchpad + for entry in WalkDir::new(fixture_dir).into_iter() { + let entry = entry?; + let src = entry.path(); + + let relative = src.strip_prefix(fixture_dir).unwrap(); + let dst = genroot.join(relative); + + if std::fs::metadata(src)?.is_dir() { + std::fs::create_dir(dst)?; + } else { + std::fs::copy(src, dst)?; + } + } + + Ok(genroot) +} + struct MockMsgReader { messages: Vec, cur: AtomicUsize, @@ -291,14 +308,14 @@ crate fn compare_json(actual: &serde_json::Value, expected: &str) { } #[derive(Clone, Copy, Debug)] -crate struct Src<'a, 'b> { +crate struct Src<'a> { crate file_name: &'a Path, // 1 indexed crate line: usize, - crate name: &'b str, + crate name: &'a str, } -crate fn src<'a, 'b>(file_name: &'a Path, line: usize, name: &'b str) -> Src<'a, 'b> { +crate fn src<'a>(file_name: &'a Path, line: usize, name: &'a str) -> Src<'a> { Src { file_name, line, @@ -319,7 +336,7 @@ impl Cache { } } - crate fn mk_ls_position(&mut self, src: Src<'_, '_>) -> ls_types::Position { + crate fn mk_ls_position(&mut self, src: Src<'_>) -> ls_types::Position { let line = self.get_line(src); let col = line .find(src.name) @@ -352,7 +369,7 @@ impl Cache { } } - fn get_line(&mut self, src: Src<'_, '_>) -> String { + fn get_line(&mut self, src: Src<'_>) -> String { let base_path = &self.base_path; let lines = self .files diff --git a/src/test/lens.rs b/src/test/lens.rs index 1eb1d9c7027..4e36b7d07ff 100644 --- a/src/test/lens.rs +++ b/src/test/lens.rs @@ -17,7 +17,7 @@ use crate::{ fn test_lens_run() { use serde_json::json; - let mut env = Environment::new("lens_run"); + let mut env = Environment::generate_from_fixture("lens_run"); let source_file_path = Path::new("src").join("main.rs"); diff --git a/src/test/mod.rs b/src/test/mod.rs index df522f101e8..f5e745bfce8 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -33,6 +33,8 @@ use std::sync::{Arc, Mutex}; use std::time::Instant; use url::Url; +pub use self::harness::FIXTURES_DIR; + fn initialize(id: usize, root_path: Option) -> Request { initialize_with_opts(id, root_path, None) } @@ -93,7 +95,7 @@ fn notification(params: A::Params) -> #[test] fn test_shutdown() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let root_path = env.cache.abs_path(Path::new(".")); @@ -126,7 +128,7 @@ fn test_shutdown() { #[test] fn test_goto_def() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -176,7 +178,7 @@ fn test_goto_def() { #[test] fn test_hover() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -226,7 +228,7 @@ fn test_hover() { /// Test hover continues to work after the source has moved line #[test] fn test_hover_after_src_line_change() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -327,7 +329,7 @@ fn test_hover_after_src_line_change() { #[test] fn test_workspace_symbol() { - let mut env = Environment::new("workspace_symbol"); + let mut env = Environment::generate_from_fixture("workspace_symbol"); let root_path = env.cache.abs_path(Path::new(".")); @@ -383,7 +385,7 @@ fn test_workspace_symbol() { #[test] fn test_workspace_symbol_duplicates() { - let mut env = Environment::new("workspace_symbol_duplicates"); + let mut env = Environment::generate_from_fixture("workspace_symbol_duplicates"); let root_path = env.cache.abs_path(Path::new(".")); @@ -441,7 +443,7 @@ fn test_workspace_symbol_duplicates() { #[test] fn test_find_all_refs() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -498,7 +500,7 @@ fn test_find_all_refs() { #[test] fn test_find_all_refs_no_cfg_test() { - let mut env = Environment::new("find_all_refs_no_cfg_test"); + let mut env = Environment::generate_from_fixture("find_all_refs_no_cfg_test"); env.with_config(|c| c.all_targets = false); let source_file_path = Path::new("src").join("main.rs"); @@ -553,7 +555,7 @@ fn test_find_all_refs_no_cfg_test() { #[test] fn test_borrow_error() { - let mut env = Environment::new("borrow_error"); + let mut env = Environment::generate_from_fixture("borrow_error"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -585,7 +587,7 @@ fn test_borrow_error() { #[test] fn test_highlight() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -638,7 +640,7 @@ fn test_highlight() { #[test] fn test_rename() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -693,7 +695,7 @@ fn test_rename() { #[test] fn test_reformat() { - let mut env = Environment::new("reformat"); + let mut env = Environment::generate_from_fixture("reformat"); let source_file_path = Path::new("src").join("main.rs"); @@ -745,7 +747,7 @@ fn test_reformat() { #[test] fn test_reformat_with_range() { - let mut env = Environment::new("reformat_with_range"); + let mut env = Environment::generate_from_fixture("reformat_with_range"); let source_file_path = Path::new("src").join("main.rs"); let root_path = env.cache.abs_path(Path::new(".")); @@ -806,7 +808,7 @@ fn test_reformat_with_range() { #[test] fn test_multiple_binaries() { - let mut env = Environment::new("multiple_bins"); + let mut env = Environment::generate_from_fixture("multiple_bins"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -846,7 +848,7 @@ fn test_multiple_binaries() { // FIXME Requires rust-src component, which would break Rust CI // #[test] // fn test_completion() { -// let mut env = Environment::new("common"); +// let mut env = Environment::generate_from_fixture("common"); // let source_file_path = Path::new("src").join("main.rs"); @@ -885,7 +887,7 @@ fn test_multiple_binaries() { #[test] fn test_bin_lib_project() { - let mut env = Environment::new("bin_lib"); + let mut env = Environment::generate_from_fixture("bin_lib"); let root_path = env.cache.abs_path(Path::new(".")); @@ -930,7 +932,7 @@ fn test_bin_lib_project() { // FIXME(#524) timing issues when run concurrently with `test_bin_lib_project` // #[test] // fn test_bin_lib_project_no_cfg_test() { -// let mut env = Environment::new("bin_lib"); +// let mut env = Environment::generate_from_fixture("bin_lib"); // let root_path = env.cache.abs_path(Path::new(".")); @@ -955,7 +957,7 @@ fn test_bin_lib_project() { // FIXME(#455) reinstate this test // #[test] // fn test_simple_workspace() { -// let mut env = Environment::new("simple_workspace"); +// let mut env = Environment::generate_from_fixture("simple_workspace"); // let root_path = env.cache.abs_path(Path::new(".")); @@ -979,7 +981,7 @@ fn test_bin_lib_project() { #[test] fn test_infer_lib() { - let mut env = Environment::new("infer_lib"); + let mut env = Environment::generate_from_fixture("infer_lib"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1015,7 +1017,7 @@ fn test_infer_lib() { #[test] fn test_infer_bin() { - let mut env = Environment::new("infer_bin"); + let mut env = Environment::generate_from_fixture("infer_bin"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1051,7 +1053,7 @@ fn test_infer_bin() { #[test] fn test_infer_custom_bin() { - let mut env = Environment::new("infer_custom_bin"); + let mut env = Environment::generate_from_fixture("infer_custom_bin"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1090,7 +1092,7 @@ fn test_infer_custom_bin() { fn test_omit_init_build() { use serde_json::json; - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let root_path = env.cache.abs_path(Path::new(".")); let root_path = root_path.as_os_str().to_str().map(|x| x.to_owned()); @@ -1117,7 +1119,7 @@ fn test_omit_init_build() { fn test_init_with_configuration() { use serde_json::json; - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let root_path = env.cache.abs_path(Path::new(".")); let root_path = root_path.as_os_str().to_str().map(|x| x.to_owned()); @@ -1193,7 +1195,7 @@ fn test_parse_error_on_malformed_input() { #[test] fn test_find_impls() { - let mut env = Environment::new("find_impls"); + let mut env = Environment::generate_from_fixture("find_impls"); let source_file_path = Path::new("src").join("main.rs"); @@ -1289,7 +1291,7 @@ fn test_find_impls() { #[test] fn test_features() { - let mut env = Environment::new("features"); + let mut env = Environment::generate_from_fixture("features"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1328,7 +1330,7 @@ fn test_features() { #[test] fn test_all_features() { - let mut env = Environment::new("features"); + let mut env = Environment::generate_from_fixture("features"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1352,7 +1354,7 @@ fn test_all_features() { #[test] fn test_no_default_features() { - let mut env = Environment::new("features"); + let mut env = Environment::generate_from_fixture("features"); let root_path = env.cache.abs_path(Path::new(".")); let messages = @@ -1394,7 +1396,7 @@ fn test_no_default_features() { // #[test] // fn test_handle_utf8_directory() { -// let mut env = Environment::new("unicødë"); +// let mut env = Environment::generate_from_fixture("unicødë"); // // let root_path = env.cache.abs_path(Path::new(".")); // let root_url = Url::from_directory_path(&root_path).unwrap(); @@ -1416,7 +1418,7 @@ fn test_no_default_features() { #[test] fn test_deglob() { - let mut env = Environment::new("deglob"); + let mut env = Environment::generate_from_fixture("deglob"); let source_file_path = Path::new("src").join("main.rs"); @@ -1635,7 +1637,7 @@ fn test_deglob() { #[test] fn test_all_targets() { - let mut env = Environment::new("bin_lib"); + let mut env = Environment::generate_from_fixture("bin_lib"); let root_path = env.cache.abs_path(Path::new(".")); @@ -1680,7 +1682,7 @@ fn test_all_targets() { /// continuing to run #[test] fn ignore_uninitialized_notification() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); @@ -1738,7 +1740,7 @@ fn ignore_uninitialized_notification() { /// and continuing to run #[test] fn fail_uninitialized_request() { - let mut env = Environment::new("common"); + let mut env = Environment::generate_from_fixture("common"); let source_file_path = Path::new("src").join("main.rs"); let root_path = env.cache.abs_path(Path::new(".")); @@ -1795,7 +1797,7 @@ fn fail_uninitialized_request() { // FIXME disabled since it is failing in the Rust repo. // #[test] // fn test_dep_fail() { -// let mut env = Environment::new("dep_fail"); +// let mut env = Environment::generate_from_fixture("dep_fail"); // let root_path = env.cache.abs_path(Path::new(".")); diff --git a/tests/fixtures/Cargo.lock b/tests/fixtures/Cargo.lock new file mode 100644 index 00000000000..24f16b782f7 --- /dev/null +++ b/tests/fixtures/Cargo.lock @@ -0,0 +1,89 @@ +[[package]] +name = "bin_lib" +version = "0.1.0" + +[[package]] +name = "borrow_error" +version = "0.1.0" + +[[package]] +name = "compile_fail" +version = "0.1.0" + +[[package]] +name = "completion" +version = "0.1.0" + +[[package]] +name = "deglob" +version = "0.1.0" + +[[package]] +name = "dep_fail" +version = "0.1.0" +dependencies = [ + "compile_fail 0.1.0", +] + +[[package]] +name = "features" +version = "0.1.0" + +[[package]] +name = "find_all_refs_no_cfg_test" +version = "0.1.0" + +[[package]] +name = "find_impls" +version = "0.1.0" + +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hover" +version = "0.1.0" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "infer_bin" +version = "0.1.0" + +[[package]] +name = "infer_custom_bin" +version = "0.1.0" + +[[package]] +name = "infer_lib" +version = "0.1.0" + +[[package]] +name = "multiple_bins" +version = "0.1.0" + +[[package]] +name = "reformat" +version = "0.1.0" + +[[package]] +name = "reformat_with_range" +version = "0.1.0" + +[[package]] +name = "run" +version = "0.1.0" + +[[package]] +name = "workspace_symbol" +version = "0.1.0" + +[[package]] +name = "workspace_symbol_duplicates" +version = "0.1.0" + +[metadata] +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" diff --git a/test_data/Cargo.toml b/tests/fixtures/Cargo.toml similarity index 100% rename from test_data/Cargo.toml rename to tests/fixtures/Cargo.toml diff --git a/test_data/bin_lib/Cargo.lock b/tests/fixtures/bin_lib/Cargo.lock similarity index 100% rename from test_data/bin_lib/Cargo.lock rename to tests/fixtures/bin_lib/Cargo.lock diff --git a/test_data/bin_lib/Cargo.toml b/tests/fixtures/bin_lib/Cargo.toml similarity index 100% rename from test_data/bin_lib/Cargo.toml rename to tests/fixtures/bin_lib/Cargo.toml diff --git a/test_data/bin_lib/src/lib.rs b/tests/fixtures/bin_lib/src/lib.rs similarity index 100% rename from test_data/bin_lib/src/lib.rs rename to tests/fixtures/bin_lib/src/lib.rs diff --git a/test_data/bin_lib/src/main.rs b/tests/fixtures/bin_lib/src/main.rs similarity index 100% rename from test_data/bin_lib/src/main.rs rename to tests/fixtures/bin_lib/src/main.rs diff --git a/test_data/bin_lib/tests/tests.rs b/tests/fixtures/bin_lib/tests/tests.rs similarity index 100% rename from test_data/bin_lib/tests/tests.rs rename to tests/fixtures/bin_lib/tests/tests.rs diff --git a/test_data/borrow_error/Cargo.lock b/tests/fixtures/borrow_error/Cargo.lock similarity index 100% rename from test_data/borrow_error/Cargo.lock rename to tests/fixtures/borrow_error/Cargo.lock diff --git a/test_data/borrow_error/Cargo.toml b/tests/fixtures/borrow_error/Cargo.toml similarity index 100% rename from test_data/borrow_error/Cargo.toml rename to tests/fixtures/borrow_error/Cargo.toml diff --git a/test_data/borrow_error/src/main.rs b/tests/fixtures/borrow_error/src/main.rs similarity index 100% rename from test_data/borrow_error/src/main.rs rename to tests/fixtures/borrow_error/src/main.rs diff --git a/test_data/common/Cargo.lock b/tests/fixtures/common/Cargo.lock similarity index 100% rename from test_data/common/Cargo.lock rename to tests/fixtures/common/Cargo.lock diff --git a/test_data/common/Cargo.toml b/tests/fixtures/common/Cargo.toml similarity index 100% rename from test_data/common/Cargo.toml rename to tests/fixtures/common/Cargo.toml diff --git a/test_data/common/src/main.rs b/tests/fixtures/common/src/main.rs similarity index 100% rename from test_data/common/src/main.rs rename to tests/fixtures/common/src/main.rs diff --git a/test_data/compile_fail/Cargo.toml b/tests/fixtures/compile_fail/Cargo.toml similarity index 100% rename from test_data/compile_fail/Cargo.toml rename to tests/fixtures/compile_fail/Cargo.toml diff --git a/test_data/compile_fail/src/lib.rs b/tests/fixtures/compile_fail/src/lib.rs similarity index 100% rename from test_data/compile_fail/src/lib.rs rename to tests/fixtures/compile_fail/src/lib.rs diff --git a/test_data/compiler_message/cannot-find-type.json b/tests/fixtures/compiler_message/cannot-find-type.json similarity index 100% rename from test_data/compiler_message/cannot-find-type.json rename to tests/fixtures/compiler_message/cannot-find-type.json diff --git a/test_data/compiler_message/clippy-const-static-lifetime.json b/tests/fixtures/compiler_message/clippy-const-static-lifetime.json similarity index 100% rename from test_data/compiler_message/clippy-const-static-lifetime.json rename to tests/fixtures/compiler_message/clippy-const-static-lifetime.json diff --git a/test_data/compiler_message/clippy-identity-op.json b/tests/fixtures/compiler_message/clippy-identity-op.json similarity index 100% rename from test_data/compiler_message/clippy-identity-op.json rename to tests/fixtures/compiler_message/clippy-identity-op.json diff --git a/test_data/compiler_message/consider-borrowing.json b/tests/fixtures/compiler_message/consider-borrowing.json similarity index 100% rename from test_data/compiler_message/consider-borrowing.json rename to tests/fixtures/compiler_message/consider-borrowing.json diff --git a/test_data/compiler_message/macro-error-no-trait.json b/tests/fixtures/compiler_message/macro-error-no-trait.json similarity index 100% rename from test_data/compiler_message/macro-error-no-trait.json rename to tests/fixtures/compiler_message/macro-error-no-trait.json diff --git a/test_data/compiler_message/macro-expected-token.json b/tests/fixtures/compiler_message/macro-expected-token.json similarity index 100% rename from test_data/compiler_message/macro-expected-token.json rename to tests/fixtures/compiler_message/macro-expected-token.json diff --git a/test_data/compiler_message/mismatched-types.json b/tests/fixtures/compiler_message/mismatched-types.json similarity index 100% rename from test_data/compiler_message/mismatched-types.json rename to tests/fixtures/compiler_message/mismatched-types.json diff --git a/test_data/compiler_message/move-out-of-borrow.json b/tests/fixtures/compiler_message/move-out-of-borrow.json similarity index 100% rename from test_data/compiler_message/move-out-of-borrow.json rename to tests/fixtures/compiler_message/move-out-of-borrow.json diff --git a/test_data/compiler_message/not-mut.json b/tests/fixtures/compiler_message/not-mut.json similarity index 100% rename from test_data/compiler_message/not-mut.json rename to tests/fixtures/compiler_message/not-mut.json diff --git a/test_data/compiler_message/type-annotations-needed.json b/tests/fixtures/compiler_message/type-annotations-needed.json similarity index 100% rename from test_data/compiler_message/type-annotations-needed.json rename to tests/fixtures/compiler_message/type-annotations-needed.json diff --git a/test_data/compiler_message/unused-use.json b/tests/fixtures/compiler_message/unused-use.json similarity index 100% rename from test_data/compiler_message/unused-use.json rename to tests/fixtures/compiler_message/unused-use.json diff --git a/test_data/compiler_message/use-after-move.json b/tests/fixtures/compiler_message/use-after-move.json similarity index 100% rename from test_data/compiler_message/use-after-move.json rename to tests/fixtures/compiler_message/use-after-move.json diff --git a/test_data/deglob/Cargo.lock b/tests/fixtures/deglob/Cargo.lock similarity index 100% rename from test_data/deglob/Cargo.lock rename to tests/fixtures/deglob/Cargo.lock diff --git a/test_data/deglob/Cargo.toml b/tests/fixtures/deglob/Cargo.toml similarity index 100% rename from test_data/deglob/Cargo.toml rename to tests/fixtures/deglob/Cargo.toml diff --git a/test_data/deglob/src/main.rs b/tests/fixtures/deglob/src/main.rs similarity index 100% rename from test_data/deglob/src/main.rs rename to tests/fixtures/deglob/src/main.rs diff --git a/test_data/dep_fail/Cargo.toml b/tests/fixtures/dep_fail/Cargo.toml similarity index 100% rename from test_data/dep_fail/Cargo.toml rename to tests/fixtures/dep_fail/Cargo.toml diff --git a/test_data/dep_fail/src/main.rs b/tests/fixtures/dep_fail/src/main.rs similarity index 100% rename from test_data/dep_fail/src/main.rs rename to tests/fixtures/dep_fail/src/main.rs diff --git a/test_data/features/Cargo.lock b/tests/fixtures/features/Cargo.lock similarity index 100% rename from test_data/features/Cargo.lock rename to tests/fixtures/features/Cargo.lock diff --git a/test_data/features/Cargo.toml b/tests/fixtures/features/Cargo.toml similarity index 100% rename from test_data/features/Cargo.toml rename to tests/fixtures/features/Cargo.toml diff --git a/test_data/features/src/main.rs b/tests/fixtures/features/src/main.rs similarity index 100% rename from test_data/features/src/main.rs rename to tests/fixtures/features/src/main.rs diff --git a/test_data/find_all_refs_no_cfg_test/Cargo.lock b/tests/fixtures/find_all_refs_no_cfg_test/Cargo.lock similarity index 100% rename from test_data/find_all_refs_no_cfg_test/Cargo.lock rename to tests/fixtures/find_all_refs_no_cfg_test/Cargo.lock diff --git a/test_data/find_all_refs_no_cfg_test/Cargo.toml b/tests/fixtures/find_all_refs_no_cfg_test/Cargo.toml similarity index 100% rename from test_data/find_all_refs_no_cfg_test/Cargo.toml rename to tests/fixtures/find_all_refs_no_cfg_test/Cargo.toml diff --git a/test_data/find_all_refs_no_cfg_test/src/main.rs b/tests/fixtures/find_all_refs_no_cfg_test/src/main.rs similarity index 100% rename from test_data/find_all_refs_no_cfg_test/src/main.rs rename to tests/fixtures/find_all_refs_no_cfg_test/src/main.rs diff --git a/test_data/find_impls/Cargo.lock b/tests/fixtures/find_impls/Cargo.lock similarity index 100% rename from test_data/find_impls/Cargo.lock rename to tests/fixtures/find_impls/Cargo.lock diff --git a/test_data/find_impls/Cargo.toml b/tests/fixtures/find_impls/Cargo.toml similarity index 100% rename from test_data/find_impls/Cargo.toml rename to tests/fixtures/find_impls/Cargo.toml diff --git a/test_data/find_impls/src/main.rs b/tests/fixtures/find_impls/src/main.rs similarity index 100% rename from test_data/find_impls/src/main.rs rename to tests/fixtures/find_impls/src/main.rs diff --git a/test_data/hover/Cargo.lock b/tests/fixtures/hover/Cargo.lock similarity index 100% rename from test_data/hover/Cargo.lock rename to tests/fixtures/hover/Cargo.lock diff --git a/test_data/hover/Cargo.toml b/tests/fixtures/hover/Cargo.toml similarity index 100% rename from test_data/hover/Cargo.toml rename to tests/fixtures/hover/Cargo.toml diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0013_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0013_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0013_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0013_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0015_007.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0015_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0015_007.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0015_007.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0017_007.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0017_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0017_007.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0017_007.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0021_013.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0021_013.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0021_013.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0021_013.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0023_009.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_009.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0023_009.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_009.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0023_016.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_016.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0023_016.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_016.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0025_008.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0025_008.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0025_008.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0025_008.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0027_008.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0027_008.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0027_008.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0027_008.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0030_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0030_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0030_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0030_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0032_010.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_010.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0032_010.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_010.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0032_019.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_019.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0032_019.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_019.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0032_026.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_026.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0032_026.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_026.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0032_035.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_035.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0032_035.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_035.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0032_049.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_049.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0032_049.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_049.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0033_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0033_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0033_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0033_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0034_016.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0034_016.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0034_016.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0034_016.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0034_023.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0034_023.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0034_023.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0034_023.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0035_016.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0035_016.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0035_016.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0035_016.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0035_023.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0035_023.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0035_023.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0035_023.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0036_016.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0036_016.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0036_016.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0036_016.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0036_023.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0036_023.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0036_023.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0036_023.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0042_015.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0042_015.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0042_015.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0042_015.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0056_006.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0056_006.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0056_006.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0056_006.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0066_006.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0066_006.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0066_006.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0066_006.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0067_030.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0067_030.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0067_030.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0067_030.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0068_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0068_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0068_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0068_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0068_026.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0068_026.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0068_026.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0068_026.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0075_010.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0075_010.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0075_010.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0075_010.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0080_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0080_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0080_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0080_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0085_014.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_014.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0085_014.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_014.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0085_050.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_050.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0085_050.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_050.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0085_054.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_054.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0085_054.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0085_054.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0086_007.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0086_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0086_007.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0086_007.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0086_010.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0086_010.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0086_010.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0086_010.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0087_020.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0087_020.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0087_020.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0087_020.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0088_018.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0088_018.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0088_018.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0088_018.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0093_011.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0093_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0093_011.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0093_011.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0093_018.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0093_018.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0093_018.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0093_018.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0095_025.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0095_025.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0095_025.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0095_025.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0109_021.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0109_021.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0109_021.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0109_021.json diff --git a/test_data/hover/save_data/test_tooltip_01.rs.0113_021.json b/tests/fixtures/hover/save_data/test_tooltip_01.rs.0113_021.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_01.rs.0113_021.json rename to tests/fixtures/hover/save_data/test_tooltip_01.rs.0113_021.json diff --git a/test_data/hover/save_data/test_tooltip_mod.rs.0022_014.json b/tests/fixtures/hover/save_data/test_tooltip_mod.rs.0022_014.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod.rs.0022_014.json rename to tests/fixtures/hover/save_data/test_tooltip_mod.rs.0022_014.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use.rs.0011_014.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0011_014.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use.rs.0011_014.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0011_014.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use.rs.0012_014.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0012_014.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use.rs.0012_014.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0012_014.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use.rs.0012_025.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0012_025.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use.rs.0012_025.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0012_025.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use.rs.0013_028.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0013_028.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use.rs.0013_028.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use.rs.0013_028.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use_external.rs.0011_007.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0011_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use_external.rs.0011_007.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0011_007.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use_external.rs.0012_007.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0012_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use_external.rs.0012_007.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0012_007.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use_external.rs.0012_012.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0012_012.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use_external.rs.0012_012.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0012_012.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use_external.rs.0014_012.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0014_012.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use_external.rs.0014_012.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0014_012.json diff --git a/test_data/hover/save_data/test_tooltip_mod_use_external.rs.0015_012.json b/tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0015_012.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_mod_use_external.rs.0015_012.json rename to tests/fixtures/hover/save_data/test_tooltip_mod_use_external.rs.0015_012.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0018_015.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0018_015.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0018_015.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0018_015.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0018_027.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0018_027.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0018_027.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0018_027.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0019_007.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0019_007.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0019_007.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0019_007.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0019_012.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0019_012.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0019_012.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0019_012.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0020_012.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0020_012.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0020_012.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0020_012.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0020_020.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0020_020.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0020_020.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0020_020.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0021_025.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0021_025.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0021_025.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0021_025.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0022_033.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0022_033.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0022_033.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0022_033.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0023_011.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0023_011.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0023_011.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0023_011.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0023_018.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0023_018.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0023_018.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0023_018.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0024_024.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0024_024.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0024_024.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0024_024.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0025_017.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0025_017.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0025_017.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0025_017.json diff --git a/test_data/hover/save_data/test_tooltip_std.rs.0025_025.json b/tests/fixtures/hover/save_data/test_tooltip_std.rs.0025_025.json similarity index 100% rename from test_data/hover/save_data/test_tooltip_std.rs.0025_025.json rename to tests/fixtures/hover/save_data/test_tooltip_std.rs.0025_025.json diff --git a/test_data/hover/src/lib.rs b/tests/fixtures/hover/src/lib.rs similarity index 100% rename from test_data/hover/src/lib.rs rename to tests/fixtures/hover/src/lib.rs diff --git a/test_data/hover/src/test_extract_decl.rs b/tests/fixtures/hover/src/test_extract_decl.rs similarity index 100% rename from test_data/hover/src/test_extract_decl.rs rename to tests/fixtures/hover/src/test_extract_decl.rs diff --git a/test_data/hover/src/test_extract_decl_multiline_empty_function.rs b/tests/fixtures/hover/src/test_extract_decl_multiline_empty_function.rs similarity index 100% rename from test_data/hover/src/test_extract_decl_multiline_empty_function.rs rename to tests/fixtures/hover/src/test_extract_decl_multiline_empty_function.rs diff --git a/test_data/hover/src/test_extract_docs_attributes.rs b/tests/fixtures/hover/src/test_extract_docs_attributes.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_attributes.rs rename to tests/fixtures/hover/src/test_extract_docs_attributes.rs diff --git a/test_data/hover/src/test_extract_docs_comment_block.rs b/tests/fixtures/hover/src/test_extract_docs_comment_block.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_comment_block.rs rename to tests/fixtures/hover/src/test_extract_docs_comment_block.rs diff --git a/test_data/hover/src/test_extract_docs_comment_first_line.rs b/tests/fixtures/hover/src/test_extract_docs_comment_first_line.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_comment_first_line.rs rename to tests/fixtures/hover/src/test_extract_docs_comment_first_line.rs diff --git a/test_data/hover/src/test_extract_docs_empty_line_before_decl.rs b/tests/fixtures/hover/src/test_extract_docs_empty_line_before_decl.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_empty_line_before_decl.rs rename to tests/fixtures/hover/src/test_extract_docs_empty_line_before_decl.rs diff --git a/test_data/hover/src/test_extract_docs_module_docs.rs b/tests/fixtures/hover/src/test_extract_docs_module_docs.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_module_docs.rs rename to tests/fixtures/hover/src/test_extract_docs_module_docs.rs diff --git a/test_data/hover/src/test_extract_docs_module_docs_no_copyright.rs b/tests/fixtures/hover/src/test_extract_docs_module_docs_no_copyright.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_module_docs_no_copyright.rs rename to tests/fixtures/hover/src/test_extract_docs_module_docs_no_copyright.rs diff --git a/test_data/hover/src/test_extract_docs_module_docs_with_attribute.rs b/tests/fixtures/hover/src/test_extract_docs_module_docs_with_attribute.rs similarity index 100% rename from test_data/hover/src/test_extract_docs_module_docs_with_attribute.rs rename to tests/fixtures/hover/src/test_extract_docs_module_docs_with_attribute.rs diff --git a/test_data/hover/src/test_tooltip_01.rs b/tests/fixtures/hover/src/test_tooltip_01.rs similarity index 100% rename from test_data/hover/src/test_tooltip_01.rs rename to tests/fixtures/hover/src/test_tooltip_01.rs diff --git a/test_data/hover/src/test_tooltip_mod.rs b/tests/fixtures/hover/src/test_tooltip_mod.rs similarity index 100% rename from test_data/hover/src/test_tooltip_mod.rs rename to tests/fixtures/hover/src/test_tooltip_mod.rs diff --git a/test_data/hover/src/test_tooltip_mod_use.rs b/tests/fixtures/hover/src/test_tooltip_mod_use.rs similarity index 100% rename from test_data/hover/src/test_tooltip_mod_use.rs rename to tests/fixtures/hover/src/test_tooltip_mod_use.rs diff --git a/test_data/hover/src/test_tooltip_mod_use_external.rs b/tests/fixtures/hover/src/test_tooltip_mod_use_external.rs similarity index 100% rename from test_data/hover/src/test_tooltip_mod_use_external.rs rename to tests/fixtures/hover/src/test_tooltip_mod_use_external.rs diff --git a/test_data/hover/src/test_tooltip_std.rs b/tests/fixtures/hover/src/test_tooltip_std.rs similarity index 100% rename from test_data/hover/src/test_tooltip_std.rs rename to tests/fixtures/hover/src/test_tooltip_std.rs diff --git a/test_data/infer_bin/Cargo.lock b/tests/fixtures/infer_bin/Cargo.lock similarity index 100% rename from test_data/infer_bin/Cargo.lock rename to tests/fixtures/infer_bin/Cargo.lock diff --git a/test_data/infer_bin/Cargo.toml b/tests/fixtures/infer_bin/Cargo.toml similarity index 100% rename from test_data/infer_bin/Cargo.toml rename to tests/fixtures/infer_bin/Cargo.toml diff --git a/test_data/infer_bin/src/main.rs b/tests/fixtures/infer_bin/src/main.rs similarity index 100% rename from test_data/infer_bin/src/main.rs rename to tests/fixtures/infer_bin/src/main.rs diff --git a/test_data/infer_custom_bin/Cargo.lock b/tests/fixtures/infer_custom_bin/Cargo.lock similarity index 100% rename from test_data/infer_custom_bin/Cargo.lock rename to tests/fixtures/infer_custom_bin/Cargo.lock diff --git a/test_data/infer_custom_bin/Cargo.toml b/tests/fixtures/infer_custom_bin/Cargo.toml similarity index 100% rename from test_data/infer_custom_bin/Cargo.toml rename to tests/fixtures/infer_custom_bin/Cargo.toml diff --git a/test_data/infer_custom_bin/src/custom_bin.rs b/tests/fixtures/infer_custom_bin/src/custom_bin.rs similarity index 100% rename from test_data/infer_custom_bin/src/custom_bin.rs rename to tests/fixtures/infer_custom_bin/src/custom_bin.rs diff --git a/test_data/infer_lib/Cargo.lock b/tests/fixtures/infer_lib/Cargo.lock similarity index 100% rename from test_data/infer_lib/Cargo.lock rename to tests/fixtures/infer_lib/Cargo.lock diff --git a/test_data/infer_lib/Cargo.toml b/tests/fixtures/infer_lib/Cargo.toml similarity index 100% rename from test_data/infer_lib/Cargo.toml rename to tests/fixtures/infer_lib/Cargo.toml diff --git a/test_data/infer_lib/src/lib.rs b/tests/fixtures/infer_lib/src/lib.rs similarity index 100% rename from test_data/infer_lib/src/lib.rs rename to tests/fixtures/infer_lib/src/lib.rs diff --git a/test_data/lens_run/Cargo.lock b/tests/fixtures/lens_run/Cargo.lock similarity index 100% rename from test_data/lens_run/Cargo.lock rename to tests/fixtures/lens_run/Cargo.lock diff --git a/test_data/lens_run/Cargo.toml b/tests/fixtures/lens_run/Cargo.toml similarity index 100% rename from test_data/lens_run/Cargo.toml rename to tests/fixtures/lens_run/Cargo.toml diff --git a/test_data/lens_run/src/main.rs b/tests/fixtures/lens_run/src/main.rs similarity index 100% rename from test_data/lens_run/src/main.rs rename to tests/fixtures/lens_run/src/main.rs diff --git a/test_data/multiple_bins/Cargo.lock b/tests/fixtures/multiple_bins/Cargo.lock similarity index 100% rename from test_data/multiple_bins/Cargo.lock rename to tests/fixtures/multiple_bins/Cargo.lock diff --git a/test_data/multiple_bins/Cargo.toml b/tests/fixtures/multiple_bins/Cargo.toml similarity index 100% rename from test_data/multiple_bins/Cargo.toml rename to tests/fixtures/multiple_bins/Cargo.toml diff --git a/test_data/multiple_bins/src/main.rs b/tests/fixtures/multiple_bins/src/main.rs similarity index 100% rename from test_data/multiple_bins/src/main.rs rename to tests/fixtures/multiple_bins/src/main.rs diff --git a/test_data/multiple_bins/src/main2.rs b/tests/fixtures/multiple_bins/src/main2.rs similarity index 100% rename from test_data/multiple_bins/src/main2.rs rename to tests/fixtures/multiple_bins/src/main2.rs diff --git a/test_data/reformat/Cargo.lock b/tests/fixtures/reformat/Cargo.lock similarity index 100% rename from test_data/reformat/Cargo.lock rename to tests/fixtures/reformat/Cargo.lock diff --git a/test_data/reformat/Cargo.toml b/tests/fixtures/reformat/Cargo.toml similarity index 100% rename from test_data/reformat/Cargo.toml rename to tests/fixtures/reformat/Cargo.toml diff --git a/test_data/reformat/rustfmt.toml b/tests/fixtures/reformat/rustfmt.toml similarity index 100% rename from test_data/reformat/rustfmt.toml rename to tests/fixtures/reformat/rustfmt.toml diff --git a/test_data/reformat/src/foo.rs b/tests/fixtures/reformat/src/foo.rs similarity index 100% rename from test_data/reformat/src/foo.rs rename to tests/fixtures/reformat/src/foo.rs diff --git a/test_data/reformat/src/main.rs b/tests/fixtures/reformat/src/main.rs similarity index 100% rename from test_data/reformat/src/main.rs rename to tests/fixtures/reformat/src/main.rs diff --git a/test_data/reformat_with_range/Cargo.lock b/tests/fixtures/reformat_with_range/Cargo.lock similarity index 100% rename from test_data/reformat_with_range/Cargo.lock rename to tests/fixtures/reformat_with_range/Cargo.lock diff --git a/test_data/reformat_with_range/Cargo.toml b/tests/fixtures/reformat_with_range/Cargo.toml similarity index 100% rename from test_data/reformat_with_range/Cargo.toml rename to tests/fixtures/reformat_with_range/Cargo.toml diff --git a/test_data/reformat_with_range/rustfmt.toml b/tests/fixtures/reformat_with_range/rustfmt.toml similarity index 100% rename from test_data/reformat_with_range/rustfmt.toml rename to tests/fixtures/reformat_with_range/rustfmt.toml diff --git a/test_data/reformat_with_range/src/main.rs b/tests/fixtures/reformat_with_range/src/main.rs similarity index 100% rename from test_data/reformat_with_range/src/main.rs rename to tests/fixtures/reformat_with_range/src/main.rs diff --git a/test_data/workspace_symbol/Cargo.lock b/tests/fixtures/workspace_symbol/Cargo.lock similarity index 100% rename from test_data/workspace_symbol/Cargo.lock rename to tests/fixtures/workspace_symbol/Cargo.lock diff --git a/test_data/workspace_symbol/Cargo.toml b/tests/fixtures/workspace_symbol/Cargo.toml similarity index 100% rename from test_data/workspace_symbol/Cargo.toml rename to tests/fixtures/workspace_symbol/Cargo.toml diff --git a/test_data/workspace_symbol/src/foo.rs b/tests/fixtures/workspace_symbol/src/foo.rs similarity index 100% rename from test_data/workspace_symbol/src/foo.rs rename to tests/fixtures/workspace_symbol/src/foo.rs diff --git a/test_data/workspace_symbol/src/main.rs b/tests/fixtures/workspace_symbol/src/main.rs similarity index 100% rename from test_data/workspace_symbol/src/main.rs rename to tests/fixtures/workspace_symbol/src/main.rs diff --git a/test_data/workspace_symbol_duplicates/Cargo.lock b/tests/fixtures/workspace_symbol_duplicates/Cargo.lock similarity index 100% rename from test_data/workspace_symbol_duplicates/Cargo.lock rename to tests/fixtures/workspace_symbol_duplicates/Cargo.lock diff --git a/test_data/workspace_symbol_duplicates/Cargo.toml b/tests/fixtures/workspace_symbol_duplicates/Cargo.toml similarity index 100% rename from test_data/workspace_symbol_duplicates/Cargo.toml rename to tests/fixtures/workspace_symbol_duplicates/Cargo.toml diff --git a/test_data/workspace_symbol_duplicates/src/main.rs b/tests/fixtures/workspace_symbol_duplicates/src/main.rs similarity index 100% rename from test_data/workspace_symbol_duplicates/src/main.rs rename to tests/fixtures/workspace_symbol_duplicates/src/main.rs diff --git a/test_data/workspace_symbol_duplicates/src/shared.rs b/tests/fixtures/workspace_symbol_duplicates/src/shared.rs similarity index 100% rename from test_data/workspace_symbol_duplicates/src/shared.rs rename to tests/fixtures/workspace_symbol_duplicates/src/shared.rs diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 8326e79e935..74907ce1c2e 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -8,21 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use serde_json; +use serde_json::{self, json}; + use std::env; -use std::fs; use std::io::{self, Read, Write}; use std::mem; use std::panic; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::{Child, ChildStdin, Command, Stdio}; use std::str; use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Duration, Instant}; -use self::paths::TestPathExt; - +pub mod project_builder; pub mod paths; /// Parse valid LSP stdout into a list of json messages @@ -287,88 +286,7 @@ impl RlsStdout { } } -#[derive(PartialEq, Clone)] -struct FileBuilder { - path: PathBuf, - body: String, -} - -impl FileBuilder { - pub fn new(path: PathBuf, body: &str) -> FileBuilder { - FileBuilder { - path, - body: body.to_string(), - } - } - - fn mk(&self) { - self.dirname().mkdir_p(); - - let mut file = fs::File::create(&self.path) - .unwrap_or_else(|e| panic!("could not create file {}: {}", self.path.display(), e)); - - file.write_all(self.body.as_bytes()).unwrap(); - } - - fn dirname(&self) -> &Path { - self.path.parent().unwrap() - } -} - -#[derive(PartialEq, Clone)] -pub struct Project { - root: PathBuf, -} - -#[must_use] -#[derive(PartialEq, Clone)] -pub struct ProjectBuilder { - root: Project, - files: Vec, -} - -impl ProjectBuilder { - pub fn new(root: PathBuf) -> ProjectBuilder { - ProjectBuilder { - root: Project { root }, - files: vec![], - } - } - - pub fn file>(mut self, path: B, body: &str) -> Self { - self._file(path.as_ref(), body); - self - } - - fn _file(&mut self, path: &Path, body: &str) { - self.files - .push(FileBuilder::new(self.root.root.join(path), body)); - } - - pub fn build(self) -> Project { - // First, clean the directory if it already exists - self.rm_root(); - - // Create the empty directory - self.root.root.mkdir_p(); - - for file in &self.files { - file.mk(); - } - - self.root - } - - fn rm_root(&self) { - self.root.root.rm_rf() - } -} - -impl Project { - pub fn root(&self) -> PathBuf { - self.root.clone() - } - +impl project_builder::Project { pub fn spawn_rls(&self) -> RlsHandle { RlsHandle::new( Command::new(rls_exe()) @@ -381,11 +299,6 @@ impl Project { } } -// Generates a project layout -pub fn project(name: &str) -> ProjectBuilder { - ProjectBuilder::new(paths::root().join(name)) -} - // Path to cargo executables pub fn target_conf_dir() -> PathBuf { let mut path = env::current_exe().unwrap(); diff --git a/tests/support/project_builder.rs b/tests/support/project_builder.rs new file mode 100644 index 00000000000..bc1792a1435 --- /dev/null +++ b/tests/support/project_builder.rs @@ -0,0 +1,129 @@ +//! Contains helper types that are capable of dynamically creating project +//! layouts under target/ for testing purposes. +//! This module is currently pulled by main binary and Cargo integration tests. +#![allow(dead_code)] + +use walkdir::WalkDir; + +use std::path::{Path, PathBuf}; +use std::fs; +use std::io::{Write}; + +use super::paths::{self, TestPathExt}; + +#[derive(PartialEq, Clone)] +struct FileBuilder { + path: PathBuf, + body: String, +} + +impl FileBuilder { + pub fn new(path: PathBuf, body: &str) -> FileBuilder { + FileBuilder { + path, + body: body.to_string(), + } + } + + fn mk(&self) { + self.dirname().mkdir_p(); + + let mut file = fs::File::create(&self.path) + .unwrap_or_else(|e| panic!("could not create file {}: {}", self.path.display(), e)); + + file.write_all(self.body.as_bytes()).unwrap(); + } + + fn dirname(&self) -> &Path { + self.path.parent().unwrap() + } +} + +#[derive(PartialEq, Clone)] +pub struct Project { + root: PathBuf, +} + +#[must_use] +#[derive(PartialEq, Clone)] +pub struct ProjectBuilder { + root: Project, + files: Vec, +} + +impl ProjectBuilder { + pub fn new(root: PathBuf) -> ProjectBuilder { + ProjectBuilder { + root: Project { root }, + files: vec![], + } + } + + pub fn try_from_fixture(fixture_dir: impl AsRef) -> std::io::Result { + let fixture_dir = fixture_dir.as_ref(); + + let dirname = fixture_dir.file_name() + .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::NotFound, "No filename"))?; + + // Generate a new, unique directory for working dir under target/ + let genroot = paths::root(); + let mut builder = ProjectBuilder::new(genroot.join(dirname)); + + // Read existing fixture data to be later copied into scratch genroot + for entry in WalkDir::new(fixture_dir).into_iter() { + let entry = entry?; + let path = entry.path(); + let body = if !std::fs::metadata(path)?.is_dir() { + std::fs::read_to_string(path)? + } else { + continue; + }; + + let relative = entry.path().strip_prefix(fixture_dir).unwrap(); + builder._file(relative, &body); + } + + Ok(builder) + } + + pub fn file>(mut self, path: B, body: &str) -> Self { + self._file(path.as_ref(), body); + self + } + + fn _file(&mut self, path: &Path, body: &str) { + self.files + .push(FileBuilder::new(self.root.root.join(path), body)); + } + + pub fn build(self) -> Project { + // First, clean the directory if it already exists + self.rm_root(); + + // Create the empty directory + self.root.root.mkdir_p(); + + for file in &self.files { + file.mk(); + } + + self.root + } + + fn rm_root(&self) { + self.root.root.rm_rf() + } +} + +impl Project { + pub fn root(&self) -> &Path { + &self.root + } +} + +// Generates a project layout +pub fn project(name: &str) -> ProjectBuilder { + ProjectBuilder::new(paths::root().join(name)) +} + + diff --git a/tests/tests.rs b/tests/tests.rs index 8021960a411..a7d1dbe4e32 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_use] -extern crate serde_json; +use serde_json::{self, json}; -mod support; - -use self::support::{basic_bin_manifest, project}; -use crate::support::RlsStdout; use std::io::Write; use std::time::Duration; +use self::support::{basic_bin_manifest, RlsStdout}; +use self::support::project_builder::project; + +mod support; + /// Returns a timeout for waiting for rls stdout messages /// /// Env var `RLS_TEST_WAIT_FOR_AGES` allows super long waiting for CI @@ -330,7 +330,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() { } ], "textDocument": { - "uri": format!("file://{}/library/src/lib.rs", root_path.as_path().display()), + "uri": format!("file://{}/library/src/lib.rs", root_path.display()), "version": 0 } })), @@ -385,7 +385,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() { } ], "textDocument": { - "uri": format!("file://{}/library/src/lib.rs", root_path.as_path().display()), + "uri": format!("file://{}/library/src/lib.rs", root_path.display()), "version": 1 } })), @@ -501,7 +501,7 @@ fn cmd_implicit_workspace_pick_up_lib_changes() { } ], "textDocument": { - "uri": format!("file://{}/inner/src/lib.rs", root_path.as_path().display()), + "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), "version": 0 } })), @@ -543,7 +543,7 @@ fn cmd_implicit_workspace_pick_up_lib_changes() { } ], "textDocument": { - "uri": format!("file://{}/inner/src/lib.rs", root_path.as_path().display()), + "uri": format!("file://{}/inner/src/lib.rs", root_path.display()), "version": 1 } })), @@ -640,7 +640,7 @@ fn cmd_test_complete_self_crate_name() { "line": 2 }, "textDocument": { - "uri": format!("file://{}/library/tests/test.rs", root_path.as_path().display()), + "uri": format!("file://{}/library/tests/test.rs", root_path.display()), "version": 1 } })), @@ -734,7 +734,7 @@ fn test_completion_suggests_arguments_in_statements() { "line": 3 }, "textDocument": { - "uri": format!("file://{}/library/tests/test.rs", root_path.as_path().display()), + "uri": format!("file://{}/library/tests/test.rs", root_path.display()), "version": 1 } })), @@ -819,7 +819,7 @@ fn test_use_statement_completion_doesnt_suggest_arguments() { "line": 2 }, "textDocument": { - "uri": format!("file://{}/library/tests/test.rs", root_path.as_path().display()), + "uri": format!("file://{}/library/tests/test.rs", root_path.display()), "version": 1 } })), @@ -924,7 +924,7 @@ fn cmd_dependency_typo_and_fix() { "workspace/didChangeWatchedFiles", Some(json!({ "changes": [{ - "uri": format!("file://{}/Cargo.toml", root_path.as_path().display()), + "uri": format!("file://{}/Cargo.toml", root_path.display()), "type": 2 }], })), @@ -951,7 +951,7 @@ fn cmd_dependency_typo_and_fix() { "workspace/didChangeWatchedFiles", Some(json!({ "changes": [{ - "uri": format!("file://{}/Cargo.toml", root_path.as_path().display()), + "uri": format!("file://{}/Cargo.toml", root_path.display()), "type": 2 }], })), @@ -1220,7 +1220,7 @@ fn cmd_handle_utf16_unit_text_edits() { "textDocument/didChange", Some(json!( {"textDocument": { - "uri": format!("file://{}/src/unrelated.rs", root_path.as_path().display()), + "uri": format!("file://{}/src/unrelated.rs", root_path.display()), "version": 1 }, // "😢" -> "" @@ -1283,7 +1283,7 @@ fn cmd_format_utf16_range() { Some(json!( { "textDocument": { - "uri": format!("file://{}/src/main.rs", root_path.as_path().display()), + "uri": format!("file://{}/src/main.rs", root_path.display()), "version": 1 }, "options": {