From 059fc8696331c2413565e8c682067c76aa6acaf8 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 5 May 2020 14:53:18 +0200 Subject: Merge heavy tests --- crates/rust-analyzer/tests/heavy_tests/main.rs | 239 +++++++++++-------------- 1 file changed, 105 insertions(+), 134 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index e94fbce3a..2e52a29a8 100644 --- a/crates/rust-analyzer/tests/heavy_tests/main.rs +++ b/crates/rust-analyzer/tests/heavy_tests/main.rs @@ -575,7 +575,7 @@ version = \"0.0.0\" } #[test] -fn resolve_include_concat_env() { +fn out_dirs_check() { if skip_slow_tests() { return; } @@ -598,11 +598,28 @@ fn main() { r#"pub fn message() -> &'static str { "Hello, World!" }"#, ) .unwrap(); + println!("cargo:rustc-cfg=atom_cfg"); + println!("cargo:rustc-cfg=featlike=\"set\""); println!("cargo:rerun-if-changed=build.rs"); } //- src/main.rs include!(concat!(env!("OUT_DIR"), "/hello.rs")); +#[cfg(atom_cfg)] +struct A; +#[cfg(bad_atom_cfg)] +struct A; +#[cfg(featlike = "set")] +struct B; +#[cfg(featlike = "not_set")] +struct B; + +fn main() { + let va = A; + let vb = B; + message(); +} + fn main() { message(); } "###, ) @@ -614,12 +631,98 @@ fn main() { message(); } let res = server.send_request::(GotoDefinitionParams { text_document_position_params: TextDocumentPositionParams::new( server.doc_id("src/main.rs"), - Position::new(2, 15), + Position::new(14, 8), ), work_done_progress_params: Default::default(), partial_result_params: Default::default(), }); assert!(format!("{}", res).contains("hello.rs")); + server.request::( + GotoDefinitionParams { + text_document_position_params: TextDocumentPositionParams::new( + server.doc_id("src/main.rs"), + Position::new(12, 9), + ), + work_done_progress_params: Default::default(), + partial_result_params: Default::default(), + }, + json!([{ + "originSelectionRange": { + "end": { + "character": 10, + "line": 12 + }, + "start": { + "character": 8, + "line": 12 + } + }, + "targetRange": { + "end": { + "character": 9, + "line": 3 + }, + "start": { + "character": 0, + "line": 2 + } + }, + "targetSelectionRange": { + "end": { + "character": 8, + "line": 3 + }, + "start": { + "character": 7, + "line": 3 + } + }, + "targetUri": "file:///[..]src/main.rs" + }]), + ); + server.request::( + GotoDefinitionParams { + text_document_position_params: TextDocumentPositionParams::new( + server.doc_id("src/main.rs"), + Position::new(13, 9), + ), + work_done_progress_params: Default::default(), + partial_result_params: Default::default(), + }, + json!([{ + "originSelectionRange": { + "end": { + "character": 10, + "line": 13 + }, + "start": { + "character": 8, + "line":13 + } + }, + "targetRange": { + "end": { + "character": 9, + "line": 7 + }, + "start": { + "character": 0, + "line":6 + } + }, + "targetSelectionRange": { + "end": { + "character": 8, + "line": 7 + }, + "start": { + "character": 7, + "line": 7 + } + }, + "targetUri": "file:///[..]src/main.rs" + }]), + ); } #[test] @@ -708,135 +811,3 @@ pub fn foo(_input: TokenStream) -> TokenStream { let value = res.get("contents").unwrap().get("value").unwrap().to_string(); assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#) } - -#[test] -fn build_rs_cfgs() { - if skip_slow_tests() { - return; - } - - let server = Project::with_fixture( - r###" -//- Cargo.toml -[package] -name = "foo" -version = "0.0.0" - -//- build.rs - -fn main() { - println!("cargo:rustc-cfg=atom_cfg"); - println!("cargo:rustc-cfg=featlike=\"set\""); - println!("cargo:rerun-if-changed=build.rs"); -} -//- src/main.rs -#[cfg(atom_cfg)] -struct A; - -#[cfg(bad_atom_cfg)] -struct A; - -#[cfg(featlike = "set")] -struct B; - -#[cfg(featlike = "not_set")] -struct B; - -fn main() { - let va = A; - let vb = B; -} -"###, - ) - .with_config(|config| { - config.cargo.load_out_dirs_from_check = true; - }) - .server(); - server.wait_until_workspace_is_loaded(); - server.request::( - GotoDefinitionParams { - text_document_position_params: TextDocumentPositionParams::new( - server.doc_id("src/main.rs"), - Position::new(13, 9), - ), - work_done_progress_params: Default::default(), - partial_result_params: Default::default(), - }, - json!([{ - "originSelectionRange": { - "end": { - "character": 10, - "line": 13 - }, - "start": { - "character": 8, - "line":13 - } - }, - "targetRange": { - "end": { - "character": 9, - "line": 1 - }, - "start": { - "character": 0, - "line":0 - } - }, - "targetSelectionRange": { - "end": { - "character": 8, - "line": 1 - }, - "start": { - "character": 7, - "line": 1 - } - }, - "targetUri": "file:///[..]src/main.rs" - }]), - ); - server.request::( - GotoDefinitionParams { - text_document_position_params: TextDocumentPositionParams::new( - server.doc_id("src/main.rs"), - Position::new(14, 9), - ), - work_done_progress_params: Default::default(), - partial_result_params: Default::default(), - }, - json!([{ - "originSelectionRange": { - "end": { - "character": 10, - "line": 14 - }, - "start": { - "character": 8, - "line":14 - } - }, - "targetRange": { - "end": { - "character": 9, - "line": 7 - }, - "start": { - "character": 0, - "line":6 - } - }, - "targetSelectionRange": { - "end": { - "character": 8, - "line": 7 - }, - "start": { - "character": 7, - "line": 7 - } - }, - "targetUri": "file:///[..]src/main.rs" - }]), - ); -} -- cgit v1.2.3