aboutsummaryrefslogtreecommitdiff
path: root/nix-rust/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-12-15 10:47:59 +0100
committerEelco Dolstra <edolstra@gmail.com>2019-12-15 10:47:59 +0100
commit410acd29c046ae7296d882ee4750441d4ff29955 (patch)
tree0900245c16f9e2d8660b1e7f01d909bfa8cdc1ae /nix-rust/src
parentacb71aa5c6a7a55bc1c483c2a6940d85997d482c (diff)
Fix cargo test
Diffstat (limited to 'nix-rust/src')
-rw-r--r--nix-rust/src/error.rs7
-rw-r--r--nix-rust/src/lib.rs1
2 files changed, 8 insertions, 0 deletions
diff --git a/nix-rust/src/error.rs b/nix-rust/src/error.rs
index 85ac926e9..9abcacc06 100644
--- a/nix-rust/src/error.rs
+++ b/nix-rust/src/error.rs
@@ -22,6 +22,7 @@ pub enum Error {
#[cfg(unused)]
HttpError(hyper::error::Error),
Misc(String),
+ #[cfg(not(test))]
Foreign(CppException),
BadTarFileMemberName(String),
}
@@ -63,6 +64,7 @@ impl fmt::Display for Error {
Error::IOError(err) => write!(f, "I/O error: {}", err),
#[cfg(unused)]
Error::HttpError(err) => write!(f, "HTTP error: {}", err),
+ #[cfg(not(test))]
Error::Foreign(_) => write!(f, "<C++ exception>"), // FIXME
Error::Misc(s) => write!(f, "{}", s),
Error::BadTarFileMemberName(s) => {
@@ -72,6 +74,7 @@ impl fmt::Display for Error {
}
}
+#[cfg(not(test))]
impl From<Error> for CppException {
fn from(err: Error) -> Self {
match err {
@@ -81,16 +84,19 @@ impl From<Error> for CppException {
}
}
+#[cfg(not(test))]
#[repr(C)]
#[derive(Debug)]
pub struct CppException(*const libc::c_void); // == std::exception_ptr*
+#[cfg(not(test))]
impl CppException {
fn new(s: &str) -> Self {
Self(unsafe { make_error(s) })
}
}
+#[cfg(not(test))]
impl Drop for CppException {
fn drop(&mut self) {
unsafe {
@@ -99,6 +105,7 @@ impl Drop for CppException {
}
}
+#[cfg(not(test))]
extern "C" {
#[allow(improper_ctypes)] // YOLO
fn make_error(s: &str) -> *const libc::c_void;
diff --git a/nix-rust/src/lib.rs b/nix-rust/src/lib.rs
index 0c3cf5276..9935cd27a 100644
--- a/nix-rust/src/lib.rs
+++ b/nix-rust/src/lib.rs
@@ -9,6 +9,7 @@ extern crate assert_matches;
#[macro_use]
extern crate proptest;
+#[cfg(not(test))]
mod c;
mod error;
mod foreign;