diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-07 19:50:00 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-07 19:50:00 +0100 |
commit | 1b136aae0b92b4b75ae1aad28ccf27d8b2b6cf73 (patch) | |
tree | e76f5011154b29d1987e098e06ae6e1d05b8f650 /crates/rust-analyzer/tests | |
parent | 97b9b364d65b00ce2246da7670a3823a0bccc1d3 (diff) | |
parent | f2dd233ddc60b647fe9c32ea2d712224005ae99e (diff) |
Merge #4296
4296: Support cargo:rustc-cfg in build.rs r=matklad a=robojumper
Fixes #4238.
Co-authored-by: robojumper <[email protected]>
Diffstat (limited to 'crates/rust-analyzer/tests')
-rw-r--r-- | crates/rust-analyzer/tests/heavy_tests/main.rs | 110 |
1 files changed, 107 insertions, 3 deletions
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index 1efa5dd63..e459e3a3c 100644 --- a/crates/rust-analyzer/tests/heavy_tests/main.rs +++ b/crates/rust-analyzer/tests/heavy_tests/main.rs | |||
@@ -9,7 +9,8 @@ use lsp_types::{ | |||
9 | }; | 9 | }; |
10 | use rust_analyzer::req::{ | 10 | use rust_analyzer::req::{ |
11 | CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, | 11 | CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, |
12 | Formatting, GotoDefinition, HoverRequest, OnEnter, Runnables, RunnablesParams, | 12 | Formatting, GotoDefinition, GotoTypeDefinition, HoverRequest, OnEnter, Runnables, |
13 | RunnablesParams, | ||
13 | }; | 14 | }; |
14 | use serde_json::json; | 15 | use serde_json::json; |
15 | use tempfile::TempDir; | 16 | use tempfile::TempDir; |
@@ -574,7 +575,7 @@ version = \"0.0.0\" | |||
574 | } | 575 | } |
575 | 576 | ||
576 | #[test] | 577 | #[test] |
577 | fn resolve_include_concat_env() { | 578 | fn out_dirs_check() { |
578 | if skip_slow_tests() { | 579 | if skip_slow_tests() { |
579 | return; | 580 | return; |
580 | } | 581 | } |
@@ -597,11 +598,28 @@ fn main() { | |||
597 | r#"pub fn message() -> &'static str { "Hello, World!" }"#, | 598 | r#"pub fn message() -> &'static str { "Hello, World!" }"#, |
598 | ) | 599 | ) |
599 | .unwrap(); | 600 | .unwrap(); |
601 | println!("cargo:rustc-cfg=atom_cfg"); | ||
602 | println!("cargo:rustc-cfg=featlike=\"set\""); | ||
600 | println!("cargo:rerun-if-changed=build.rs"); | 603 | println!("cargo:rerun-if-changed=build.rs"); |
601 | } | 604 | } |
602 | //- src/main.rs | 605 | //- src/main.rs |
603 | include!(concat!(env!("OUT_DIR"), "/hello.rs")); | 606 | include!(concat!(env!("OUT_DIR"), "/hello.rs")); |
604 | 607 | ||
608 | #[cfg(atom_cfg)] | ||
609 | struct A; | ||
610 | #[cfg(bad_atom_cfg)] | ||
611 | struct A; | ||
612 | #[cfg(featlike = "set")] | ||
613 | struct B; | ||
614 | #[cfg(featlike = "not_set")] | ||
615 | struct B; | ||
616 | |||
617 | fn main() { | ||
618 | let va = A; | ||
619 | let vb = B; | ||
620 | message(); | ||
621 | } | ||
622 | |||
605 | fn main() { message(); } | 623 | fn main() { message(); } |
606 | "###, | 624 | "###, |
607 | ) | 625 | ) |
@@ -613,12 +631,98 @@ fn main() { message(); } | |||
613 | let res = server.send_request::<GotoDefinition>(GotoDefinitionParams { | 631 | let res = server.send_request::<GotoDefinition>(GotoDefinitionParams { |
614 | text_document_position_params: TextDocumentPositionParams::new( | 632 | text_document_position_params: TextDocumentPositionParams::new( |
615 | server.doc_id("src/main.rs"), | 633 | server.doc_id("src/main.rs"), |
616 | Position::new(2, 15), | 634 | Position::new(14, 8), |
617 | ), | 635 | ), |
618 | work_done_progress_params: Default::default(), | 636 | work_done_progress_params: Default::default(), |
619 | partial_result_params: Default::default(), | 637 | partial_result_params: Default::default(), |
620 | }); | 638 | }); |
621 | assert!(format!("{}", res).contains("hello.rs")); | 639 | assert!(format!("{}", res).contains("hello.rs")); |
640 | server.request::<GotoTypeDefinition>( | ||
641 | GotoDefinitionParams { | ||
642 | text_document_position_params: TextDocumentPositionParams::new( | ||
643 | server.doc_id("src/main.rs"), | ||
644 | Position::new(12, 9), | ||
645 | ), | ||
646 | work_done_progress_params: Default::default(), | ||
647 | partial_result_params: Default::default(), | ||
648 | }, | ||
649 | json!([{ | ||
650 | "originSelectionRange": { | ||
651 | "end": { | ||
652 | "character": 10, | ||
653 | "line": 12 | ||
654 | }, | ||
655 | "start": { | ||
656 | "character": 8, | ||
657 | "line": 12 | ||
658 | } | ||
659 | }, | ||
660 | "targetRange": { | ||
661 | "end": { | ||
662 | "character": 9, | ||
663 | "line": 3 | ||
664 | }, | ||
665 | "start": { | ||
666 | "character": 0, | ||
667 | "line": 2 | ||
668 | } | ||
669 | }, | ||
670 | "targetSelectionRange": { | ||
671 | "end": { | ||
672 | "character": 8, | ||
673 | "line": 3 | ||
674 | }, | ||
675 | "start": { | ||
676 | "character": 7, | ||
677 | "line": 3 | ||
678 | } | ||
679 | }, | ||
680 | "targetUri": "file:///[..]src/main.rs" | ||
681 | }]), | ||
682 | ); | ||
683 | server.request::<GotoTypeDefinition>( | ||
684 | GotoDefinitionParams { | ||
685 | text_document_position_params: TextDocumentPositionParams::new( | ||
686 | server.doc_id("src/main.rs"), | ||
687 | Position::new(13, 9), | ||
688 | ), | ||
689 | work_done_progress_params: Default::default(), | ||
690 | partial_result_params: Default::default(), | ||
691 | }, | ||
692 | json!([{ | ||
693 | "originSelectionRange": { | ||
694 | "end": { | ||
695 | "character": 10, | ||
696 | "line": 13 | ||
697 | }, | ||
698 | "start": { | ||
699 | "character": 8, | ||
700 | "line":13 | ||
701 | } | ||
702 | }, | ||
703 | "targetRange": { | ||
704 | "end": { | ||
705 | "character": 9, | ||
706 | "line": 7 | ||
707 | }, | ||
708 | "start": { | ||
709 | "character": 0, | ||
710 | "line":6 | ||
711 | } | ||
712 | }, | ||
713 | "targetSelectionRange": { | ||
714 | "end": { | ||
715 | "character": 8, | ||
716 | "line": 7 | ||
717 | }, | ||
718 | "start": { | ||
719 | "character": 7, | ||
720 | "line": 7 | ||
721 | } | ||
722 | }, | ||
723 | "targetUri": "file:///[..]src/main.rs" | ||
724 | }]), | ||
725 | ); | ||
622 | } | 726 | } |
623 | 727 | ||
624 | #[test] | 728 | #[test] |