mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Merge heavy tests
This commit is contained in:
parent
2980ba1fde
commit
059fc86963
1 changed files with 105 additions and 134 deletions
|
@ -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::<GotoDefinition>(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::<GotoTypeDefinition>(
|
||||
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::<GotoTypeDefinition>(
|
||||
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::<GotoTypeDefinition>(
|
||||
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::<GotoTypeDefinition>(
|
||||
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"
|
||||
}]),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue