Fix cargo test

This commit is contained in:
Eelco Dolstra 2019-12-15 10:47:59 +01:00
parent acb71aa5c6
commit 410acd29c0
2 changed files with 8 additions and 0 deletions

View file

@ -22,6 +22,7 @@ pub enum Error {
#[cfg(unused)] #[cfg(unused)]
HttpError(hyper::error::Error), HttpError(hyper::error::Error),
Misc(String), Misc(String),
#[cfg(not(test))]
Foreign(CppException), Foreign(CppException),
BadTarFileMemberName(String), BadTarFileMemberName(String),
} }
@ -63,6 +64,7 @@ impl fmt::Display for Error {
Error::IOError(err) => write!(f, "I/O error: {}", err), Error::IOError(err) => write!(f, "I/O error: {}", err),
#[cfg(unused)] #[cfg(unused)]
Error::HttpError(err) => write!(f, "HTTP error: {}", err), Error::HttpError(err) => write!(f, "HTTP error: {}", err),
#[cfg(not(test))]
Error::Foreign(_) => write!(f, "<C++ exception>"), // FIXME Error::Foreign(_) => write!(f, "<C++ exception>"), // FIXME
Error::Misc(s) => write!(f, "{}", s), Error::Misc(s) => write!(f, "{}", s),
Error::BadTarFileMemberName(s) => { Error::BadTarFileMemberName(s) => {
@ -72,6 +74,7 @@ impl fmt::Display for Error {
} }
} }
#[cfg(not(test))]
impl From<Error> for CppException { impl From<Error> for CppException {
fn from(err: Error) -> Self { fn from(err: Error) -> Self {
match err { match err {
@ -81,16 +84,19 @@ impl From<Error> for CppException {
} }
} }
#[cfg(not(test))]
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
pub struct CppException(*const libc::c_void); // == std::exception_ptr* pub struct CppException(*const libc::c_void); // == std::exception_ptr*
#[cfg(not(test))]
impl CppException { impl CppException {
fn new(s: &str) -> Self { fn new(s: &str) -> Self {
Self(unsafe { make_error(s) }) Self(unsafe { make_error(s) })
} }
} }
#[cfg(not(test))]
impl Drop for CppException { impl Drop for CppException {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
@ -99,6 +105,7 @@ impl Drop for CppException {
} }
} }
#[cfg(not(test))]
extern "C" { extern "C" {
#[allow(improper_ctypes)] // YOLO #[allow(improper_ctypes)] // YOLO
fn make_error(s: &str) -> *const libc::c_void; fn make_error(s: &str) -> *const libc::c_void;

View file

@ -9,6 +9,7 @@ extern crate assert_matches;
#[macro_use] #[macro_use]
extern crate proptest; extern crate proptest;
#[cfg(not(test))]
mod c; mod c;
mod error; mod error;
mod foreign; mod foreign;