From 89b600628d5aeaa81d3f7a7821c2b8939fd4d583 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Sun, 22 May 2016 13:35:30 -0400 Subject: [PATCH] tests: move macros into separate module --- tests/common/macros.rs | 48 +++++++++++++++++++++++++++++++++++++++++ tests/common/mod.rs | 1 + tests/common/util.rs | 49 ------------------------------------------ 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100755 tests/common/macros.rs diff --git a/tests/common/macros.rs b/tests/common/macros.rs new file mode 100755 index 000000000..c0005125b --- /dev/null +++ b/tests/common/macros.rs @@ -0,0 +1,48 @@ +#[macro_export] +macro_rules! assert_empty_stderr( + ($cond:expr) => ( + if $cond.stderr.len() > 0 { + panic!(format!("stderr: {}", $cond.stderr)) + } + ); +); + +#[macro_export] +macro_rules! assert_empty_stdout( + ($cond:expr) => ( + if $cond.stdout.len() > 0 { + panic!(format!("stdout: {}", $cond.stdout)) + } + ); +); + +#[macro_export] +macro_rules! assert_no_error( + ($cond:expr) => ( + assert!($cond.success); + if $cond.stderr.len() > 0 { + panic!(format!("stderr: {}", $cond.stderr)) + } + ); +); + +#[macro_export] +macro_rules! path_concat { + ($e:expr, ..$n:expr) => {{ + use std::path::PathBuf; + let n = $n; + let mut pb = PathBuf::new(); + for _ in 0..n { + pb.push($e); + } + pb.to_str().unwrap().to_owned() + }}; + ($($e:expr),*) => {{ + use std::path::PathBuf; + let mut pb = PathBuf::new(); + $( + pb.push($e); + )* + pb.to_str().unwrap().to_owned() + }}; +} diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 870edd9ff..3fcd90441 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,2 +1,3 @@ #[macro_use] +pub mod macros; pub mod util; diff --git a/tests/common/util.rs b/tests/common/util.rs index 1e3d42a14..5fc599b50 100755 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -30,34 +30,6 @@ static ALREADY_RUN: &'static str = " you have already run this UCommand, if you testing();"; static MULTIPLE_STDIN_MEANINGLESS: &'static str = "Ucommand is designed around a typical use case of: provide args and input stream -> spawn process -> block until completion -> return output streams. For verifying that a particular section of the input stream is what causes a particular behavior, use the Command type directly."; -#[macro_export] -macro_rules! assert_empty_stderr( - ($cond:expr) => ( - if $cond.stderr.len() > 0 { - panic!(format!("stderr: {}", $cond.stderr)) - } - ); -); - -#[macro_export] -macro_rules! assert_empty_stdout( - ($cond:expr) => ( - if $cond.stdout.len() > 0 { - panic!(format!("stdout: {}", $cond.stdout)) - } - ); -); - -#[macro_export] -macro_rules! assert_no_error( - ($cond:expr) => ( - assert!($cond.success); - if $cond.stderr.len() > 0 { - panic!(format!("stderr: {}", $cond.stderr)) - } - ); -); - pub fn repeat_str(s: &str, n: u32) -> String { let mut repeated = String::new(); for _ in 0..n { @@ -66,27 +38,6 @@ pub fn repeat_str(s: &str, n: u32) -> String { repeated } -#[macro_export] -macro_rules! path_concat { - ($e:expr, ..$n:expr) => {{ - use std::path::PathBuf; - let n = $n; - let mut pb = PathBuf::new(); - for _ in 0..n { - pb.push($e); - } - pb.to_str().unwrap().to_owned() - }}; - ($($e:expr),*) => {{ - use std::path::PathBuf; - let mut pb = PathBuf::new(); - $( - pb.push($e); - )* - pb.to_str().unwrap().to_owned() - }}; -} - pub struct CmdResult { pub success: bool, pub stdout: String,