Skip to content

Commit

Permalink
Add custom error type for tests
Browse files Browse the repository at this point in the history
This error type is used only for tests and makes stacktraces generated
by the Rust test runner point to the exact place when an error was
encountered.

Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
  • Loading branch information
wiktor-k committed Aug 17, 2021
1 parent 27b5d1b commit 1662920
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cryptoki/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ use cryptoki::types::mechanism::Mechanism;
use cryptoki::types::object::{Attribute, AttributeInfo, AttributeType, KeyType, ObjectClass};
use cryptoki::types::session::UserType;
use cryptoki::types::Flags;
use cryptoki::Result;
use serial_test::serial;
use std::sync::Arc;
use std::thread;

#[derive(Debug)]
struct ErrorWithStacktrace;

impl<T: std::error::Error> From<T> for ErrorWithStacktrace {
fn from(p: T) -> Self {
panic!("Error: {:#?}", p);
}
}

type Result<T> = std::result::Result<T, ErrorWithStacktrace>;

#[test]
#[serial]
fn sign_verify() -> Result<()> {
Expand Down

0 comments on commit 1662920

Please sign in to comment.