mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 19:27:30 +03:00
refactor: remove TestAttr and pass --include-ignored to test runnables
This commit is contained in:
@@ -898,9 +898,6 @@ fn my_cool_test() {}
|
||||
test_id: Path(
|
||||
"tests::my_cool_test",
|
||||
),
|
||||
attr: TestAttr {
|
||||
ignore: false,
|
||||
},
|
||||
},
|
||||
cfg: None,
|
||||
update_test: UpdateTest {
|
||||
|
||||
@@ -3526,9 +3526,6 @@ fn foo_$0test() {}
|
||||
test_id: Path(
|
||||
"foo_test",
|
||||
),
|
||||
attr: TestAttr {
|
||||
ignore: false,
|
||||
},
|
||||
},
|
||||
cfg: None,
|
||||
update_test: UpdateTest {
|
||||
@@ -10707,9 +10704,6 @@ macro_rules! str {
|
||||
test_id: Path(
|
||||
"test",
|
||||
),
|
||||
attr: TestAttr {
|
||||
ignore: false,
|
||||
},
|
||||
},
|
||||
cfg: None,
|
||||
update_test: UpdateTest {
|
||||
@@ -10778,9 +10772,6 @@ macro_rules! expect {
|
||||
test_id: Path(
|
||||
"test",
|
||||
),
|
||||
attr: TestAttr {
|
||||
ignore: false,
|
||||
},
|
||||
},
|
||||
cfg: None,
|
||||
update_test: UpdateTest {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use arrayvec::ArrayVec;
|
||||
use ast::HasName;
|
||||
use cfg::{CfgAtom, CfgExpr};
|
||||
use hir::{AsAssocItem, HasAttrs, HasCrate, HasSource, Semantics, Symbol, db::HirDatabase, sym};
|
||||
use hir::{AsAssocItem, HasAttrs, HasCrate, HasSource, Semantics, Symbol, sym};
|
||||
use ide_assists::utils::{has_test_related_attribute, test_related_attribute_syn};
|
||||
use ide_db::impl_empty_upmap_from_ra_fixture;
|
||||
use ide_db::{
|
||||
@@ -55,7 +55,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
pub enum RunnableKind {
|
||||
TestMod { path: String },
|
||||
Test { test_id: TestId, attr: TestAttr },
|
||||
Test { test_id: TestId },
|
||||
Bench { test_id: TestId },
|
||||
DocTest { test_id: TestId },
|
||||
Bin,
|
||||
@@ -334,8 +334,7 @@ pub(crate) fn runnable_fn(
|
||||
};
|
||||
|
||||
if def.is_test(sema.db) {
|
||||
let attr = TestAttr::from_fn(sema.db, def);
|
||||
RunnableKind::Test { test_id: test_id(), attr }
|
||||
RunnableKind::Test { test_id: test_id() }
|
||||
} else if def.is_bench(sema.db) {
|
||||
RunnableKind::Bench { test_id: test_id() }
|
||||
} else {
|
||||
@@ -558,17 +557,6 @@ fn module_def_doctest(sema: &Semantics<'_, RootDatabase>, def: Definition) -> Op
|
||||
Some(res)
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct TestAttr {
|
||||
pub ignore: bool,
|
||||
}
|
||||
|
||||
impl TestAttr {
|
||||
fn from_fn(db: &dyn HirDatabase, fn_def: hir::Function) -> TestAttr {
|
||||
TestAttr { ignore: fn_def.is_ignore(db) }
|
||||
}
|
||||
}
|
||||
|
||||
fn has_runnable_doc_test(db: &RootDatabase, attrs: &hir::AttrsWithOwner) -> bool {
|
||||
const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
|
||||
const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] =
|
||||
|
||||
@@ -274,15 +274,13 @@ fn executable_args_for(
|
||||
let mut executable_args = Vec::new();
|
||||
|
||||
match kind {
|
||||
RunnableKind::Test { test_id, attr } => {
|
||||
RunnableKind::Test { test_id } => {
|
||||
executable_args.push(test_id.to_string());
|
||||
if let TestId::Path(_) = test_id {
|
||||
executable_args.push("--exact".to_owned());
|
||||
}
|
||||
executable_args.extend(extra_test_binary_args);
|
||||
if attr.ignore {
|
||||
executable_args.push("--ignored".to_owned());
|
||||
}
|
||||
executable_args.push("--include-ignored".to_owned());
|
||||
}
|
||||
RunnableKind::TestMod { path } => {
|
||||
executable_args.push(path.clone());
|
||||
|
||||
@@ -262,7 +262,7 @@ fn main() {}
|
||||
{
|
||||
"args": {
|
||||
"cargoArgs": ["test", "--package", "foo", "--test", "spam"],
|
||||
"executableArgs": ["test_eggs", "--exact", "--nocapture"],
|
||||
"executableArgs": ["test_eggs", "--exact", "--nocapture", "--include-ignored"],
|
||||
"overrideCargo": null,
|
||||
"cwd": server.path().join("foo"),
|
||||
"workspaceRoot": server.path().join("foo")
|
||||
|
||||
Reference in New Issue
Block a user