-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run & Debug links gone in VS Code 1.74.1 with Rust Analyzer v0.3.1325 #18
Comments
Thx for reporting. I will have a look. |
Sorry for the very late delay. Just had a look how the I have a simple test: #[test]
#[ntest::timeout(1000)]
fn timeout_test() {
assert!(false);
} Which expands to: extern crate test;
#[cfg(test)]
#[rustc_test_marker = "timeout_test"]
pub const timeout_test: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("timeout_test"),
ignore: false,
ignore_message: ::core::option::Option::None,
source_file: "tests\\end_to_end.rs",
start_line: 12usize,
start_col: 4usize,
end_line: 12usize,
end_col: 16usize,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::IntegrationTest,
},
testfn: test::StaticTestFn(|| test::assert_test_result(timeout_test())),
};
fn timeout_test() {
fn ntest_callback() {
if !false {
::core::panicking::panic("assertion failed: false")
}
}
let ntest_timeout_now = std::time::Instant::now();
let (sender, receiver) = std::sync::mpsc::channel();
std::thread::spawn(move || { if let Ok(()) = sender.send(ntest_callback()) {} });
match receiver.recv_timeout(std::time::Duration::from_millis(1000u64)) {
Ok(t) => return t,
Err(std::sync::mpsc::RecvTimeoutError::Timeout) => {
::std::rt::panic_fmt(
format_args!(
"timeout: the function call took {0} ms. Max time {1} ms",
ntest_timeout_now.elapsed().as_millis(),
1000u64,
),
);
}
Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => {
::std::rt::begin_panic("explicit panic")
}
}
} I see that rust analyzer fails to interprete this and does not show the Without using the timeout macro it would have expanded to: extern crate test;
#[cfg(test)]
#[rustc_test_marker = "timeout_test"]
pub const timeout_test: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("timeout_test"),
ignore: false,
ignore_message: ::core::option::Option::None,
source_file: "tests\\end_to_end.rs",
start_line: 11usize,
start_col: 4usize,
end_line: 11usize,
end_col: 16usize,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::IntegrationTest,
},
testfn: test::StaticTestFn(|| test::assert_test_result(timeout_test())),
};
fn timeout_test() {
if !false {
::core::panicking::panic("assertion failed: false")
}
} |
Just a guess but I think the macros are expanded differently when this is performed by RA. I have no other sensible expalnation for panic happening in #23 when using RA but not when building code with Cargo. I hope to look into this issue from RA side but cannot give any ETA. |
Given the discussion in rust-lang/rust-analyzer#11109 I do believe there is nothing left to fix in this crate and missing test/debug button is RA bug. As a workaround I think it should be possible to provide workaround attribute like that but I'd have to experiment with it first:
|
Description
VS Code has a pair of handy links for running or debugging individual tests. But when
#[ntest::timeout(1000)]
is placed, they are removed.To Reproduce
Put
#[ntest::timeout(1000)]
over the testing function.Expected behavior
"Run" and "Debug" links should remain.
Screenshots
example
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: