mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #1532 (@rivy; refactor ~ tests reorganization)
This commit is contained in:
commit
a307335c41
97 changed files with 82 additions and 117 deletions
|
@ -16,7 +16,6 @@ categories = ["command-line-utilities"]
|
|||
edition = "2018"
|
||||
|
||||
build = "build.rs"
|
||||
autotests = false
|
||||
|
||||
[features]
|
||||
default = [ "feat_common_core" ]
|
||||
|
@ -347,6 +346,3 @@ unix_socket = "0.5.0"
|
|||
[[bin]]
|
||||
name = "coreutils"
|
||||
path = "src/bin/coreutils.rs"
|
||||
|
||||
[[test]]
|
||||
name = "tests"
|
||||
|
|
73
build.rs
73
build.rs
|
@ -6,6 +6,8 @@ use std::io::Write;
|
|||
use std::path::Path;
|
||||
|
||||
pub fn main() {
|
||||
// println!("cargo:warning=Running build.rs");
|
||||
|
||||
if let Ok(profile) = env::var("PROFILE") {
|
||||
println!("cargo:rustc-cfg=build={:?}", profile);
|
||||
}
|
||||
|
@ -15,6 +17,11 @@ pub fn main() {
|
|||
let override_prefix: &str = "uu_";
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
// println!("cargo:warning=out_dir={}", out_dir);
|
||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap().replace("\\", "/");
|
||||
// println!("cargo:warning=manifest_dir={}", manifest_dir);
|
||||
let util_tests_dir = format!("{}/tests/by-util", manifest_dir);
|
||||
// println!("cargo:warning=util_tests_dir={}", util_tests_dir);
|
||||
|
||||
let mut crates = Vec::new();
|
||||
for (key, val) in env::vars() {
|
||||
|
@ -33,6 +40,7 @@ pub fn main() {
|
|||
crates.sort();
|
||||
|
||||
let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap();
|
||||
let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap();
|
||||
|
||||
mf.write_all(
|
||||
"type UtilityMap = HashMap<&'static str, fn(Vec<String>) -> i32>;\n\
|
||||
|
@ -46,8 +54,8 @@ pub fn main() {
|
|||
|
||||
for krate in crates {
|
||||
match krate.as_ref() {
|
||||
k if k.starts_with(override_prefix) => mf
|
||||
.write_all(
|
||||
k if k.starts_with(override_prefix) => {
|
||||
mf.write_all(
|
||||
format!(
|
||||
"\tmap.insert(\"{k}\", {krate}::uumain);\n",
|
||||
k = krate[override_prefix.len()..].to_string(),
|
||||
|
@ -55,18 +63,38 @@ pub fn main() {
|
|||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap(),
|
||||
"false" | "true" => mf
|
||||
.write_all(
|
||||
.unwrap();
|
||||
tf.write_all(
|
||||
format!(
|
||||
"#[path=\"{dir}/test_{k}.rs\"]\nmod test_{k};\n",
|
||||
k = krate[override_prefix.len()..].to_string(),
|
||||
dir = util_tests_dir,
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
"false" | "true" => {
|
||||
mf.write_all(
|
||||
format!(
|
||||
"\tmap.insert(\"{krate}\", r#{krate}::uumain);\n",
|
||||
krate = krate
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap(),
|
||||
"hashsum" => mf
|
||||
.write_all(
|
||||
.unwrap();
|
||||
tf.write_all(
|
||||
format!(
|
||||
"#[path=\"{dir}/test_{krate}.rs\"]\nmod test_{krate};\n",
|
||||
krate = krate,
|
||||
dir = util_tests_dir,
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
"hashsum" => {
|
||||
mf.write_all(
|
||||
format!(
|
||||
"\
|
||||
\tmap.insert(\"{krate}\", {krate}::uumain);\n\
|
||||
|
@ -88,20 +116,41 @@ pub fn main() {
|
|||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap(),
|
||||
_ => mf
|
||||
.write_all(
|
||||
.unwrap();
|
||||
tf.write_all(
|
||||
format!(
|
||||
"#[path=\"{dir}/test_{krate}.rs\"]\nmod test_{krate};\n",
|
||||
krate = krate,
|
||||
dir = util_tests_dir,
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
_ => {
|
||||
mf.write_all(
|
||||
format!(
|
||||
"\tmap.insert(\"{krate}\", {krate}::uumain);\n",
|
||||
krate = krate
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap(),
|
||||
.unwrap();
|
||||
tf.write_all(
|
||||
format!(
|
||||
"#[path=\"{dir}/test_{krate}.rs\"]\nmod test_{krate};\n",
|
||||
krate = krate,
|
||||
dir = util_tests_dir,
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mf.write_all(b"map\n}\n").unwrap();
|
||||
|
||||
mf.flush().unwrap();
|
||||
tf.flush().unwrap();
|
||||
}
|
||||
|
|
1
tests/by-util/test_chroot.rs
Normal file
1
tests/by-util/test_chroot.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
use crate::common::util::*;
|
||||
|
||||
#[path = "../src/uu/factor/sieve.rs"]
|
||||
#[path = "../../src/uu/factor/sieve.rs"]
|
||||
mod sieve;
|
||||
use self::sieve::Sieve;
|
||||
|
1
tests/by-util/test_groups.rs
Normal file
1
tests/by-util/test_groups.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_hostid.rs
Normal file
1
tests/by-util/test_hostid.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_kill.rs
Normal file
1
tests/by-util/test_kill.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_logname.rs
Normal file
1
tests/by-util/test_logname.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_mkfifo.rs
Normal file
1
tests/by-util/test_mkfifo.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_mknod.rs
Normal file
1
tests/by-util/test_mknod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_nice.rs
Normal file
1
tests/by-util/test_nice.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_nohup.rs
Normal file
1
tests/by-util/test_nohup.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_nproc.rs
Normal file
1
tests/by-util/test_nproc.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_relpath.rs
Normal file
1
tests/by-util/test_relpath.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_shred.rs
Normal file
1
tests/by-util/test_shred.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_shuf.rs
Normal file
1
tests/by-util/test_shuf.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_sleep.rs
Normal file
1
tests/by-util/test_sleep.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_sync.rs
Normal file
1
tests/by-util/test_sync.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_tee.rs
Normal file
1
tests/by-util/test_tee.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_timeout.rs
Normal file
1
tests/by-util/test_timeout.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_tty.rs
Normal file
1
tests/by-util/test_tty.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
1
tests/by-util/test_yes.rs
Normal file
1
tests/by-util/test_yes.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// ToDO: add tests
|
101
tests/tests.rs
101
tests/tests.rs
|
@ -9,103 +9,4 @@ extern crate lazy_static;
|
|||
#[cfg(unix)]
|
||||
extern crate rust_users;
|
||||
|
||||
// For conditional compilation
|
||||
macro_rules! unix_only {
|
||||
($($fea:expr, $m:ident);+) => {
|
||||
$(
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = $fea)]
|
||||
mod $m;
|
||||
)+
|
||||
};
|
||||
}
|
||||
unix_only! {
|
||||
"chmod", test_chmod;
|
||||
"chown", test_chown;
|
||||
"chgrp", test_chgrp;
|
||||
"install", test_install;
|
||||
"pathchk", test_pathchk;
|
||||
"pinky", test_pinky;
|
||||
"stdbuf", test_stdbuf;
|
||||
"uname", test_uname;
|
||||
"unlink", test_unlink;
|
||||
"uptime", test_uptime;
|
||||
"users", test_users;
|
||||
"who", test_who;
|
||||
// Be aware of the trailing semicolon after the last item
|
||||
"stat", test_stat
|
||||
}
|
||||
|
||||
macro_rules! generic {
|
||||
($($fea:expr, $m:ident);+) => {
|
||||
$(
|
||||
#[cfg(feature = $fea)]
|
||||
mod $m;
|
||||
)+
|
||||
};
|
||||
}
|
||||
generic! {
|
||||
"arch", test_arch;
|
||||
"base32", test_base32;
|
||||
"base64", test_base64;
|
||||
"basename", test_basename;
|
||||
"cat", test_cat;
|
||||
"cksum", test_cksum;
|
||||
"comm", test_comm;
|
||||
"cp", test_cp;
|
||||
"cut", test_cut;
|
||||
"date", test_date;
|
||||
"dircolors", test_dircolors;
|
||||
"dirname", test_dirname;
|
||||
"df", test_df;
|
||||
"du", test_du;
|
||||
"echo", test_echo;
|
||||
"env", test_env;
|
||||
"expand", test_expand;
|
||||
"expr", test_expr;
|
||||
"factor", test_factor;
|
||||
"false", test_false;
|
||||
"fmt", test_fmt;
|
||||
"fold", test_fold;
|
||||
"hashsum", test_hashsum;
|
||||
"head", test_head;
|
||||
"id", test_id;
|
||||
"join", test_join;
|
||||
"link", test_link;
|
||||
"ln", test_ln;
|
||||
"ls", test_ls;
|
||||
"mkdir", test_mkdir;
|
||||
"mktemp", test_mktemp;
|
||||
"more", test_more;
|
||||
"mv", test_mv;
|
||||
"numfmt", test_numfmt;
|
||||
"nl", test_nl;
|
||||
"od", test_od;
|
||||
"paste", test_paste;
|
||||
"printenv", test_printenv;
|
||||
"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;
|
||||
"touch", test_touch;
|
||||
"tr", test_tr;
|
||||
"true", test_true;
|
||||
"truncate", test_truncate;
|
||||
"tsort", test_tsort;
|
||||
"unexpand", test_unexpand;
|
||||
"uniq", test_uniq;
|
||||
"wc", test_wc;
|
||||
"whoami", test_whoami;
|
||||
// Be aware of the trailing semicolon after the last item
|
||||
"hostname", test_hostname
|
||||
}
|
||||
include!(concat!(env!("OUT_DIR"), "/test_modules.rs"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue