Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #21921 from Amit5601/fix-test-ignored-flag
fix: unconditionally pass --include-ignored for test runnables
Chayim Refael Friedman 7 weeks ago
parent 9af7449 · parent 41596b6 · commit 1fd88f5
-rw-r--r--crates/ide/src/annotations.rs3
-rw-r--r--crates/ide/src/hover/tests.rs9
-rw-r--r--crates/ide/src/runnables.rs18
-rw-r--r--crates/rust-analyzer/src/target_spec.rs6
-rw-r--r--crates/rust-analyzer/tests/slow-tests/main.rs2
5 files changed, 6 insertions, 32 deletions
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index 107977cb11..21b2339c72 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -898,9 +898,6 @@ mod tests {
test_id: Path(
"tests::my_cool_test",
),
- attr: TestAttr {
- ignore: false,
- },
},
cfg: None,
update_test: UpdateTest {
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 7a758cd4c1..56cf959fa0 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -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 @@ pub use expect_test;
test_id: Path(
"test",
),
- attr: TestAttr {
- ignore: false,
- },
},
cfg: None,
update_test: UpdateTest {
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index a0a6a24559..7b8313b4cb 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -3,7 +3,7 @@ use std::{fmt, sync::OnceLock};
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 @@ impl fmt::Display for TestId {
#[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] =
diff --git a/crates/rust-analyzer/src/target_spec.rs b/crates/rust-analyzer/src/target_spec.rs
index 8be061cacf..c1d52e4c9b 100644
--- a/crates/rust-analyzer/src/target_spec.rs
+++ b/crates/rust-analyzer/src/target_spec.rs
@@ -274,15 +274,13 @@ impl CargoTargetSpec {
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());
diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs
index fcdc8bb7cd..3c57e36b4f 100644
--- a/crates/rust-analyzer/tests/slow-tests/main.rs
+++ b/crates/rust-analyzer/tests/slow-tests/main.rs
@@ -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")