Skip to content

Commit 1fd88f5

Browse files
Merge pull request #21921 from Amit5601/fix-test-ignored-flag
fix: unconditionally pass --include-ignored for test runnables
2 parents 9af7449 + 41596b6 commit 1fd88f5

5 files changed

Lines changed: 6 additions & 32 deletions

File tree

crates/ide/src/annotations.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,6 @@ mod tests {
898898
test_id: Path(
899899
"tests::my_cool_test",
900900
),
901-
attr: TestAttr {
902-
ignore: false,
903-
},
904901
},
905902
cfg: None,
906903
update_test: UpdateTest {

crates/ide/src/hover/tests.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,9 +3526,6 @@ fn foo_$0test() {}
35263526
test_id: Path(
35273527
"foo_test",
35283528
),
3529-
attr: TestAttr {
3530-
ignore: false,
3531-
},
35323529
},
35333530
cfg: None,
35343531
update_test: UpdateTest {
@@ -10707,9 +10704,6 @@ macro_rules! str {
1070710704
test_id: Path(
1070810705
"test",
1070910706
),
10710-
attr: TestAttr {
10711-
ignore: false,
10712-
},
1071310707
},
1071410708
cfg: None,
1071510709
update_test: UpdateTest {
@@ -10778,9 +10772,6 @@ pub use expect_test;
1077810772
test_id: Path(
1077910773
"test",
1078010774
),
10781-
attr: TestAttr {
10782-
ignore: false,
10783-
},
1078410775
},
1078510776
cfg: None,
1078610777
update_test: UpdateTest {

crates/ide/src/runnables.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{fmt, sync::OnceLock};
33
use arrayvec::ArrayVec;
44
use ast::HasName;
55
use cfg::{CfgAtom, CfgExpr};
6-
use hir::{AsAssocItem, HasAttrs, HasCrate, HasSource, Semantics, Symbol, db::HirDatabase, sym};
6+
use hir::{AsAssocItem, HasAttrs, HasCrate, HasSource, Semantics, Symbol, sym};
77
use ide_assists::utils::{has_test_related_attribute, test_related_attribute_syn};
88
use ide_db::impl_empty_upmap_from_ra_fixture;
99
use ide_db::{
@@ -55,7 +55,7 @@ impl fmt::Display for TestId {
5555
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
5656
pub enum RunnableKind {
5757
TestMod { path: String },
58-
Test { test_id: TestId, attr: TestAttr },
58+
Test { test_id: TestId },
5959
Bench { test_id: TestId },
6060
DocTest { test_id: TestId },
6161
Bin,
@@ -334,8 +334,7 @@ pub(crate) fn runnable_fn(
334334
};
335335

336336
if def.is_test(sema.db) {
337-
let attr = TestAttr::from_fn(sema.db, def);
338-
RunnableKind::Test { test_id: test_id(), attr }
337+
RunnableKind::Test { test_id: test_id() }
339338
} else if def.is_bench(sema.db) {
340339
RunnableKind::Bench { test_id: test_id() }
341340
} else {
@@ -558,17 +557,6 @@ fn module_def_doctest(sema: &Semantics<'_, RootDatabase>, def: Definition) -> Op
558557
Some(res)
559558
}
560559

561-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
562-
pub struct TestAttr {
563-
pub ignore: bool,
564-
}
565-
566-
impl TestAttr {
567-
fn from_fn(db: &dyn HirDatabase, fn_def: hir::Function) -> TestAttr {
568-
TestAttr { ignore: fn_def.is_ignore(db) }
569-
}
570-
}
571-
572560
fn has_runnable_doc_test(db: &RootDatabase, attrs: &hir::AttrsWithOwner) -> bool {
573561
const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
574562
const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] =

crates/rust-analyzer/src/target_spec.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,13 @@ impl CargoTargetSpec {
274274
let mut executable_args = Vec::new();
275275

276276
match kind {
277-
RunnableKind::Test { test_id, attr } => {
277+
RunnableKind::Test { test_id } => {
278278
executable_args.push(test_id.to_string());
279279
if let TestId::Path(_) = test_id {
280280
executable_args.push("--exact".to_owned());
281281
}
282282
executable_args.extend(extra_test_binary_args);
283-
if attr.ignore {
284-
executable_args.push("--ignored".to_owned());
285-
}
283+
executable_args.push("--include-ignored".to_owned());
286284
}
287285
RunnableKind::TestMod { path } => {
288286
executable_args.push(path.clone());

crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn main() {}
262262
{
263263
"args": {
264264
"cargoArgs": ["test", "--package", "foo", "--test", "spam"],
265-
"executableArgs": ["test_eggs", "--exact", "--nocapture"],
265+
"executableArgs": ["test_eggs", "--exact", "--nocapture", "--include-ignored"],
266266
"overrideCargo": null,
267267
"cwd": server.path().join("foo"),
268268
"workspaceRoot": server.path().join("foo")

0 commit comments

Comments
 (0)