Skip to content

Commit 62db8f6

Browse files
committed
Implement test explorer
1 parent 9d0ccf0 commit 62db8f6

31 files changed

+3191
-113
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ide-db/src/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl SearchScope {
9393
}
9494

9595
/// Build a search scope spanning the entire crate graph of files.
96-
fn crate_graph(db: &RootDatabase) -> SearchScope {
96+
pub fn crate_graph(db: &RootDatabase) -> SearchScope {
9797
let mut entries = IntMap::default();
9898

9999
let graph = db.crate_graph();

crates/ide/src/annotations.rs

Lines changed: 92 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -744,89 +744,109 @@ mod tests {
744744
}
745745
"#,
746746
expect![[r#"
747-
[
748-
Annotation {
749-
range: 3..7,
750-
kind: Runnable(
751-
Runnable {
752-
use_name_in_title: false,
753-
nav: NavigationTarget {
754-
file_id: FileId(
755-
0,
756-
),
757-
full_range: 0..12,
758-
focus_range: 3..7,
759-
name: "main",
760-
kind: Function,
761-
},
762-
kind: Bin,
763-
cfg: None,
747+
[
748+
Annotation {
749+
range: 3..7,
750+
kind: Runnable(
751+
Runnable {
752+
use_name_in_title: false,
753+
nav: NavigationTarget {
754+
file_id: FileId(
755+
0,
756+
),
757+
full_range: 0..12,
758+
focus_range: 3..7,
759+
name: "main",
760+
kind: Function,
764761
},
765-
),
766-
},
767-
Annotation {
768-
range: 18..23,
769-
kind: Runnable(
770-
Runnable {
771-
use_name_in_title: false,
772-
nav: NavigationTarget {
773-
file_id: FileId(
774-
0,
775-
),
776-
full_range: 14..64,
777-
focus_range: 18..23,
778-
name: "tests",
779-
kind: Module,
780-
description: "mod tests",
781-
},
782-
kind: TestMod {
783-
path: "tests",
784-
},
785-
cfg: None,
762+
kind: Bin,
763+
cfg: None,
764+
},
765+
),
766+
},
767+
Annotation {
768+
range: 18..23,
769+
kind: Runnable(
770+
Runnable {
771+
use_name_in_title: false,
772+
nav: NavigationTarget {
773+
file_id: FileId(
774+
0,
775+
),
776+
full_range: 14..64,
777+
focus_range: 18..23,
778+
name: "tests",
779+
kind: Module,
780+
description: "mod tests",
786781
},
787-
),
788-
},
789-
Annotation {
790-
range: 45..57,
791-
kind: Runnable(
792-
Runnable {
793-
use_name_in_title: false,
794-
nav: NavigationTarget {
795-
file_id: FileId(
796-
0,
797-
),
798-
full_range: 30..62,
799-
focus_range: 45..57,
800-
name: "my_cool_test",
801-
kind: Function,
802-
},
803-
kind: Test {
804-
test_id: Path(
805-
"tests::my_cool_test",
806-
),
807-
attr: TestAttr {
808-
ignore: false,
809-
},
782+
kind: TestMod {
783+
path: "tests",
784+
},
785+
cfg: None,
786+
},
787+
),
788+
},
789+
Annotation {
790+
range: 45..57,
791+
kind: Runnable(
792+
Runnable {
793+
use_name_in_title: false,
794+
nav: NavigationTarget {
795+
file_id: FileId(
796+
0,
797+
),
798+
full_range: 30..62,
799+
focus_range: 45..57,
800+
name: "my_cool_test",
801+
kind: Function,
802+
},
803+
kind: Test {
804+
test_id: Path(
805+
"tests::my_cool_test",
806+
),
807+
attr: TestAttr {
808+
ignore: false,
810809
},
811-
cfg: None,
812810
},
813-
),
814-
},
815-
Annotation {
816-
range: 3..7,
817-
kind: HasReferences {
818-
pos: FilePosition {
811+
cfg: None,
812+
},
813+
),
814+
},
815+
Annotation {
816+
range: 0..77,
817+
kind: Runnable(
818+
Runnable {
819+
use_name_in_title: false,
820+
nav: NavigationTarget {
819821
file_id: FileId(
820822
0,
821823
),
822-
offset: 3,
824+
full_range: 0..77,
825+
name: "",
826+
kind: Module,
823827
},
824-
data: Some(
825-
[],
828+
kind: TestMod {
829+
path: "",
830+
},
831+
cfg: None,
832+
},
833+
),
834+
},
835+
Annotation {
836+
range: 3..7,
837+
kind: HasReferences {
838+
pos: FilePosition {
839+
file_id: FileId(
840+
0,
826841
),
842+
offset: 3,
827843
},
844+
data: Some(
845+
[],
846+
),
828847
},
829-
]
848+
},
849+
]
830850
"#]],
831851
);
832852
}

crates/ide/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ mod parent_module;
4747
mod references;
4848
mod rename;
4949
mod runnables;
50+
mod test_items;
5051
mod ssr;
5152
mod static_index;
5253
mod status;
@@ -552,6 +553,10 @@ impl Analysis {
552553
self.with_db(|db| runnables::runnables(db, file_id))
553554
}
554555

556+
pub fn test_runnables_in_file(&self, file_id: FileId) -> Cancellable<Vec<Runnable>> {
557+
self.with_db(|db| test_items::test_runnables_in_file(db, file_id))
558+
}
559+
555560
/// Returns the set of tests for the given file position.
556561
pub fn related_tests(
557562
&self,

0 commit comments

Comments
 (0)