Conditionally compile test modules

This commit is contained in:
Knight 2016-06-12 15:02:05 +08:00
parent e87407f598
commit 1695441880
3 changed files with 80 additions and 56 deletions

View file

@ -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

View file

@ -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";

View file

@ -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
}