Comments (9)
Yeah... you are right. Thanks to report it.
I don't know when I can publish the new version.... sorry
from rstest.
Sure. I think you should also consider a downcast for String
in addition to &str
. I didn't noticed it at first, but the assert!
macros and panic("{}", "something")
produce a String
instead of a &str
. Could you also remove the panic message of the unnamed
thread, please?
from rstest.
Ok.
from rstest.
Great! Thanks.
from rstest.
Ok, I fixed the String
casting but I don't found a clear and clean way to remove the unnamed
thread: I should run another thread to implement timeout (timeout should be in the current thread) and this message will contain the original stack trace and correct error coordinates.
The only way that I found to catch the stack trace is to use something like described in https://stackoverflow.com/questions/69593235/how-to-get-panic-information-i-e-stack-trace-with-catch-unwind but it seams a little bit overkilled and it will not prevent the panic
output.
If you are ok I'm incline to close this ticket now.... If you have some ideas of how to move the panic from other thread to test thread I would really happy to hear you.
from rstest.
Great thanks for your work.
Oh I see. You want to preserve the backtrace, what's pretty cool. After a lot of searching and reading through the stdlib, I found a nice and simple solution.
pub fn execute_with_timeout_sync<T: 'static + Send, F: FnOnce() -> T + Send + 'static>(
code: F,
timeout: Duration,
) -> T {
let (sender, receiver) = mpsc::channel();
let thread = if let Some(name) = thread::current().name() {
std::thread::Builder::new().name(name.to_string())
} else {
std::thread::Builder::new()
};
let handle = thread.spawn(move || sender.send(code())).unwrap();
match receiver.recv_timeout(timeout) {
Ok(result) => {
// Unwraps are safe because we got a result from the thread, which is not a `SendError`,
// and there was no panic within the thread which caused a disconnect.
handle.join().unwrap().unwrap();
result
}
Err(RecvTimeoutError::Timeout) => {
panic!("Timeout {:?} expired", timeout)
}
Err(RecvTimeoutError::Disconnected) => match handle.join() {
Ok(_) => unreachable!(),
Err(any) => {
panic::resume_unwind(any);
}
},
}
}
Sorry, I've written this on the base of an older commit on the main branch, but I hope you get the idea.
from rstest.
from rstest.
Sure :)
from rstest.
THX again
from rstest.
Related Issues (20)
- Allow `clippy::too_many_arguments` HOT 6
- Please clearly state the MSRV in the README and documentation and use the "rust-version" flag. HOT 2
- Add capability to ignore arguments HOT 3
- [vscode] text wrapping for run/debug test buttons
- Misleading error messaging when defining a test that includes a lifetime argument HOT 1
- Support argument destructuring for `#[values(...)]` HOT 1
- Injecting static types HOT 5
- Create a fixture from `files` attribute HOT 3
- skip cases based on feature flag? HOT 5
- `#[once]` fixtures are unsound for types that are not `Sync` HOT 4
- clippy::duplicated_attributes warning with rust 1.79.0-nightly HOT 3
- By-reference fixtures HOT 12
- Update `rstest_reuse` docs and release new version
- `#[from(source)]` should accept path also and not just idents
- rstest_reuse: "the `async` keyword is missing from the function declaration" HOT 1
- replace return <expr>; with <expr> [needless_return] HOT 3
- Support dynamic `#[values]` HOT 1
- Feature: Optional label in the `#[case...]` HOT 1
- Dynamically set #[values(..)] HOT 1
- New test files are only recognized after `cargo clean` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rstest.