Merge pull request #18643 from Veykril/push-muwuzmowptnn

internal: Rename test fixture crates to ra_test_fixture
This commit is contained in:
Lukas Wirth 2024-12-09 10:54:51 +00:00 committed by GitHub
commit bdb2a3e182
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 407 additions and 397 deletions

View file

@ -1,6 +1,5 @@
mod block;
use base_db::SourceDatabase;
use expect_test::{expect, Expect};
use test_fixture::WithFixture;
@ -11,7 +10,7 @@ use super::*;
fn lower(ra_fixture: &str) -> (TestDB, Arc<Body>, DefWithBodyId) {
let db = TestDB::with_files(ra_fixture);
let krate = db.crate_graph().iter().next().unwrap();
let krate = db.fetch_test_crate();
let def_map = db.crate_def_map(krate);
let mut fn_def = None;
'outer: for (_, module) in def_map.modules() {

View file

@ -16,7 +16,6 @@ mod proc_macros;
use std::{iter, ops::Range, sync};
use base_db::SourceDatabase;
use expect_test::Expect;
use hir_expand::{
db::ExpandDatabase,
@ -63,7 +62,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
},
)];
let db = TestDB::with_files_extra_proc_macros(ra_fixture, extra_proc_macros);
let krate = db.crate_graph().iter().next().unwrap();
let krate = db.fetch_test_crate();
let def_map = db.crate_def_map(krate);
let local_id = DefMap::ROOT;
let module = def_map.module_id(local_id);

View file

@ -13,13 +13,13 @@ use crate::{db::DefDatabase, nameres::DefMap, test_db::TestDB};
fn compute_crate_def_map(ra_fixture: &str) -> Arc<DefMap> {
let db = TestDB::with_files(ra_fixture);
let krate = db.crate_graph().iter().next().unwrap();
let krate = db.fetch_test_crate();
db.crate_def_map(krate)
}
fn render_crate_def_map(ra_fixture: &str) -> String {
let db = TestDB::with_files(ra_fixture);
let krate = db.crate_graph().iter().next().unwrap();
let krate = db.fetch_test_crate();
db.crate_def_map(krate).dump(&db)
}

View file

@ -1,16 +1,11 @@
use base_db::{SourceDatabase, SourceDatabaseFileInputExt as _};
use base_db::SourceDatabaseFileInputExt as _;
use test_fixture::WithFixture;
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};
fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);
let krate = {
let crate_graph = db.crate_graph();
// Some of these tests use minicore/proc-macros which will be injected as the first crate
let krate = crate_graph.iter().next().unwrap();
krate
};
let krate = db.fetch_test_crate();
{
let events = db.log_executed(|| {
db.crate_def_map(krate);
@ -121,6 +116,8 @@ fn f() { foo }
);
}
// Would be nice if this was the case, but as attribute inputs are stored in the item tree, this is
// not currently the case.
// #[test]
// fn typing_inside_an_attribute_arg_should_not_invalidate_def_map() {
// check_def_map_is_not_recomputed(
@ -200,6 +197,8 @@ pub struct S {}
);
}
// Would be nice if this was the case, but as attribute inputs are stored in the item tree, this is
// not currently the case.
// #[test]
// fn typing_inside_a_derive_should_not_invalidate_def_map() {
// check_def_map_is_not_recomputed(

View file

@ -78,6 +78,19 @@ impl FileLoader for TestDB {
}
impl TestDB {
pub(crate) fn fetch_test_crate(&self) -> CrateId {
let crate_graph = self.crate_graph();
let it = crate_graph
.iter()
.find(|&idx| {
crate_graph[idx].display_name.as_ref().map(|it| it.canonical_name().as_str())
== Some("ra_test_fixture")
})
.or_else(|| crate_graph.iter().next())
.unwrap();
it
}
pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId {
for &krate in self.relevant_crates(file_id).iter() {
let crate_def_map = self.crate_def_map(krate);

View file

@ -88,7 +88,7 @@ pub(crate) fn generate_documentation_template(
// /// # Examples
// ///
// /// ```
// /// use test::add;
// /// use ra_test_fixture::add;
// ///
// /// assert_eq!(add(a, b), );
// /// ```
@ -596,7 +596,7 @@ pub fn noop_with_param(_a: i32) {}
/// # Examples
///
/// ```
/// use test::noop_with_param;
/// use ra_test_fixture::noop_with_param;
///
/// noop_with_param(_a);
/// ```
@ -641,7 +641,7 @@ pub unsafe fn noop_unsafe() {}
/// # Examples
///
/// ```
/// use test::noop_unsafe;
/// use ra_test_fixture::noop_unsafe;
///
/// unsafe { noop_unsafe() };
/// ```
@ -758,7 +758,7 @@ pub fn returns_a_value$0() -> i32 {
/// # Examples
///
/// ```
/// use test::returns_a_value;
/// use ra_test_fixture::returns_a_value;
///
/// assert_eq!(returns_a_value(), );
/// ```
@ -807,7 +807,7 @@ pub fn modifies_a_value$0(a: &mut i32) {
/// # Examples
///
/// ```
/// use test::modifies_a_value;
/// use ra_test_fixture::modifies_a_value;
///
/// let mut a = ;
/// modifies_a_value(&mut a);
@ -836,7 +836,7 @@ pub fn sum3$0(a: i32, b: i32, c: i32) -> i32 {
/// # Examples
///
/// ```
/// use test::sum3;
/// use ra_test_fixture::sum3;
///
/// let result = sum3(a, b, c);
/// assert_eq!(result, );
@ -868,7 +868,7 @@ pub mod a {
/// # Examples
///
/// ```
/// use test::a::b::noop;
/// use ra_test_fixture::a::b::noop;
///
/// noop();
/// ```
@ -898,7 +898,7 @@ impl MyStruct {
/// # Examples
///
/// ```
/// use test::MyStruct;
/// use ra_test_fixture::MyStruct;
///
/// MyStruct::noop();
/// ```
@ -1169,7 +1169,7 @@ impl<T> MyGenericStruct<T> {
/// # Examples
///
/// ```
/// use test::MyGenericStruct;
/// use ra_test_fixture::MyGenericStruct;
///
/// let my_generic_struct = ;
/// my_generic_struct.consume();
@ -1199,7 +1199,7 @@ impl<T> MyGenericStruct<T> {
/// # Examples
///
/// ```
/// use test::MyGenericStruct;
/// use ra_test_fixture::MyGenericStruct;
///
/// let mut my_generic_struct = ;
/// my_generic_struct.modify(new_value);

View file

@ -1392,7 +1392,7 @@ pub fn add(a: i32, b: i32) -> i32 { a + b }
/// # Examples
///
/// ```
/// use test::add;
/// use ra_test_fixture::add;
///
/// assert_eq!(add(a, b), );
/// ```

File diff suppressed because it is too large Load diff

View file

@ -236,7 +236,7 @@ impl ChangeFixture {
crate_graph.add_crate_root(
crate_root,
Edition::CURRENT,
Some(CrateName::new("test").unwrap().into()),
Some(CrateName::new("ra_test_fixture").unwrap().into()),
None,
From::from(default_cfg.clone()),
Some(From::from(default_cfg)),