From 169544188076413237556a74baad524d629de871 Mon Sep 17 00:00:00 2001 From: Knight Date: Sun, 12 Jun 2016 15:02:05 +0800 Subject: [PATCH] Conditionally compile test modules --- Makefile | 2 +- tests/test_tail.rs | 2 +- tests/tests.rs | 132 ++++++++++++++++++++++++++------------------- 3 files changed, 80 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index e7abc7007..a9d32b70f 100644 --- a/Makefile +++ b/Makefile @@ -202,7 +202,7 @@ endef define TEST_INTEGRATION test_integration_$(1): build_exe_$(1) - ${CARGO} test ${CARGOFLAGS} --test $(1) --features "$(1) $(TEST_SPEC_FEATURE)" --no-default-features $(TEST_NO_FAIL_FAST) + ${CARGO} test ${CARGOFLAGS} --features "$(1) $(TEST_SPEC_FEATURE)" --no-default-features $(TEST_NO_FAIL_FAST) endef define TEST_BUSYBOX diff --git a/tests/test_tail.rs b/tests/test_tail.rs index 4f5f117bd..bd6f3fb1d 100644 --- a/tests/test_tail.rs +++ b/tests/test_tail.rs @@ -3,7 +3,7 @@ extern crate uu_tail; use common::util::*; use std::char::from_digit; use std::io::Write; -use uu_tail::parse_size; +use self::uu_tail::parse_size; static UTIL_NAME: &'static str = "tail"; diff --git a/tests/tests.rs b/tests/tests.rs index 1f07567f5..aa8abf797 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -4,7 +4,6 @@ extern crate rand; extern crate regex; extern crate tempdir; extern crate time; -extern crate uu_tail; #[cfg(windows)] extern crate kernel32; #[cfg(windows)] extern crate winapi; @@ -15,57 +14,82 @@ mod common; #[path="../src/factor/sieve.rs"] mod sieve; -#[cfg(unix)] mod test_chmod; -#[cfg(unix)] mod test_mv; -#[cfg(unix)] mod test_pathchk; -#[cfg(unix)] mod test_stdbuf; -#[cfg(unix)] mod test_touch; -#[cfg(unix)] mod test_unlink; -#[cfg(unix)] mod test_stat; +// For conditional compilation +macro_rules! unix_only { + ($($fea:expr, $m:ident);+) => { + $( + #[cfg(unix)] + #[cfg(feature = $fea)] + mod $m; + )+ + }; +} +unix_only! { + "chmod", test_chmod; + "mv", test_mv; + "pathchk", test_pathchk; + "stdbuf", test_stdbuf; + "touch", test_touch; + "unlink", test_unlink; + // Be aware of the trailing semicolon after the last item + "stat", test_stat +} -mod test_base64; -mod test_basename; -mod test_cat; -mod test_cksum; -mod test_comm; -mod test_cp; -mod test_cut; -mod test_dircolors; -mod test_dirname; -mod test_echo; -mod test_env; -mod test_expr; -mod test_factor; -mod test_false; -mod test_fold; -mod test_hashsum; -mod test_head; -mod test_link; -mod test_ln; -mod test_ls; -mod test_mkdir; -mod test_mktemp; -mod test_nl; -mod test_od; -mod test_paste; -mod test_printf; -mod test_ptx; -mod test_pwd; -mod test_readlink; -mod test_realpath; -mod test_rm; -mod test_rmdir; -mod test_seq; -mod test_sort; -mod test_split; -mod test_sum; -mod test_tac; -mod test_tail; -mod test_test; -mod test_tr; -mod test_true; -mod test_truncate; -mod test_tsort; -mod test_unexpand; -mod test_uniq; -mod test_wc; + +macro_rules! generic { + ($($fea:expr, $m:ident);+) => { + $( + #[cfg(feature = $fea)] + mod $m; + )+ + }; +} +generic! { + "base64", test_base64; + "basename", test_basename; + "cat", test_cat; + "cksum", test_cksum; + "comm", test_comm; + "cp", test_cp; + "cut", test_cut; + "dircolors", test_dircolors; + "dirname", test_dirname; + "echo", test_echo; + "env", test_env; + "expr", test_expr; + "factor", test_factor; + "false", test_false; + "fold", test_fold; + "hashsum", test_hashsum; + "head", test_head; + "link", test_link; + "ln", test_ln; + "ls", test_ls; + "mkdir", test_mkdir; + "mktemp", test_mktemp; + "nl", test_nl; + "od", test_od; + "paste", test_paste; + "printf", test_printf; + "ptx", test_ptx; + "pwd", test_pwd; + "readlink", test_readlink; + "realpath", test_realpath; + "rm", test_rm; + "rmdir", test_rmdir; + "seq", test_seq; + "sort", test_sort; + "split", test_split; + "sum", test_sum; + "tac", test_tac; + "tail", test_tail; + "test", test_test; + "tr", test_tr; + "true", test_true; + "truncate", test_truncate; + "tsort", test_tsort; + "unexpand", test_unexpand; + "uniq", test_uniq; + // Be aware of the trailing semicolon after the last item + "wc", test_wc +}