mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #728 from jbcrail/fix-namespace-collision
Fix namespace collision for test.
This commit is contained in:
commit
282df37a02
6 changed files with 19 additions and 30 deletions
|
@ -65,7 +65,7 @@ all = [
|
||||||
"tac",
|
"tac",
|
||||||
"tail",
|
"tail",
|
||||||
"tee",
|
"tee",
|
||||||
"test_uu",
|
"test",
|
||||||
"timeout",
|
"timeout",
|
||||||
"touch",
|
"touch",
|
||||||
"tr",
|
"tr",
|
||||||
|
@ -143,7 +143,7 @@ sync = { optional=true, path="src/sync" }
|
||||||
tac = { optional=true, path="src/tac" }
|
tac = { optional=true, path="src/tac" }
|
||||||
tail = { optional=true, path="src/tail" }
|
tail = { optional=true, path="src/tail" }
|
||||||
tee = { optional=true, path="src/tee" }
|
tee = { optional=true, path="src/tee" }
|
||||||
test_uu = { optional=true, path="src/test" }
|
test = { optional=true, path="src/test" }
|
||||||
timeout = { optional=true, path="src/timeout" }
|
timeout = { optional=true, path="src/timeout" }
|
||||||
touch = { optional=true, path="src/touch" }
|
touch = { optional=true, path="src/touch" }
|
||||||
tr = { optional=true, path="src/tr" }
|
tr = { optional=true, path="src/tr" }
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -67,7 +67,7 @@ PROGS := \
|
||||||
sync \
|
sync \
|
||||||
tac \
|
tac \
|
||||||
tee \
|
tee \
|
||||||
test_uu \
|
test \
|
||||||
tr \
|
tr \
|
||||||
true \
|
true \
|
||||||
truncate \
|
truncate \
|
||||||
|
@ -163,7 +163,7 @@ build_exe_$(1):
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define TEST_INTEGRATION
|
define TEST_INTEGRATION
|
||||||
test_integration_$(1):
|
test_integration_$(1): build_exe_$(1)
|
||||||
${CARGO} test --test $(1) --features $(1) --no-default-features
|
${CARGO} test --test $(1) --features $(1) --no-default-features
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -206,11 +206,10 @@ use_default := 1
|
||||||
|
|
||||||
$(foreach util,$(EXES),$(eval $(call BUILD_EXE,$(util))))
|
$(foreach util,$(EXES),$(eval $(call BUILD_EXE,$(util))))
|
||||||
|
|
||||||
build-uutils:
|
build-uutils: $(addprefix build_exe_,$(EXES))
|
||||||
${CARGO} build --features "${EXES}" ${PROFILE_CMD} --no-default-features
|
${CARGO} build --features "${EXES}" ${PROFILE_CMD} --no-default-features
|
||||||
|
|
||||||
build: build-uutils $(addprefix build_exe_,$(EXES))
|
build: build-uutils
|
||||||
$(foreach util, ${EXES}, $(call build_pkg, ${util}))
|
|
||||||
|
|
||||||
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
|
$(foreach test,$(TESTS),$(eval $(call TEST_INTEGRATION,$(test))))
|
||||||
$(foreach test,$(TESTS),$(eval $(call TEST_UNIT,$(test))))
|
$(foreach test,$(TESTS),$(eval $(call TEST_UNIT,$(test))))
|
||||||
|
|
14
build.rs
14
build.rs
|
@ -29,8 +29,7 @@ pub fn main() {
|
||||||
let mut map: UtilityMap = HashMap::new();\n".as_bytes()).unwrap();
|
let mut map: UtilityMap = HashMap::new();\n".as_bytes()).unwrap();
|
||||||
for krate in crates {
|
for krate in crates {
|
||||||
match krate.as_ref() {
|
match krate.as_ref() {
|
||||||
"false" => {},
|
"false" | "true" | "test" => {},
|
||||||
"true" => {},
|
|
||||||
_ => cf.write_all(format!("extern crate {krate} as uu{krate};\n", krate=krate).as_bytes()).unwrap(),
|
_ => cf.write_all(format!("extern crate {krate} as uu{krate};\n", krate=krate).as_bytes()).unwrap(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +43,11 @@ pub fn main() {
|
||||||
map.insert(\"sha384sum\", uuhashsum::uumain);
|
map.insert(\"sha384sum\", uuhashsum::uumain);
|
||||||
map.insert(\"sha512sum\", uuhashsum::uumain);\n".as_bytes()).unwrap();
|
map.insert(\"sha512sum\", uuhashsum::uumain);\n".as_bytes()).unwrap();
|
||||||
},
|
},
|
||||||
"false" =>
|
"false" | "true" | "test" => {
|
||||||
mf.write_all("fn uufalse(_: Vec<String>) -> i32 { 1 }
|
mf.write_all(format!("fn uu{}", krate).as_bytes()).unwrap();
|
||||||
map.insert(\"false\", uufalse as fn(Vec<String>) -> i32);\n".as_bytes()).unwrap(),
|
mf.write_all("(_: Vec<String>) -> i32 { 1 }\n".as_bytes()).unwrap();
|
||||||
"true" =>
|
mf.write_all(format!("map.insert(\"{krate}\", uu{krate} as fn(Vec<String>) -> i32);\n", krate=krate).as_bytes()).unwrap();
|
||||||
mf.write_all("fn uutrue(_: Vec<String>) -> i32 { 0 }
|
},
|
||||||
map.insert(\"true\", uutrue as fn(Vec<String>) -> i32);\n".as_bytes()).unwrap(),
|
|
||||||
_ =>
|
_ =>
|
||||||
mf.write_all(format!("map.insert(\"{krate}\", uu{krate}::uumain as fn(Vec<String>) -> i32);\n", krate= krate).as_bytes()).unwrap(),
|
mf.write_all(format!("map.insert(\"{krate}\", uu{krate}::uumain as fn(Vec<String>) -> i32);\n", krate= krate).as_bytes()).unwrap(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
[package]
|
[package]
|
||||||
name = "test_uu"
|
name = "test"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = []
|
authors = []
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "test_uu"
|
name = "uutest"
|
||||||
path = "test.rs"
|
path = "test.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -13,5 +13,5 @@ libc = "*"
|
||||||
uucore = { path="../uucore" }
|
uucore = { path="../uucore" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name="test"
|
name="uutest"
|
||||||
path="test.rs"
|
path="test.rs"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![crate_name = "test_uu"]
|
#![crate_name = "uutest"]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the uutils coreutils package.
|
* This file is part of the uutils coreutils package.
|
||||||
|
|
|
@ -20,21 +20,13 @@ static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/uutils_map.rs"));
|
include!(concat!(env!("OUT_DIR"), "/uutils_map.rs"));
|
||||||
|
|
||||||
fn name_sub(util_name: &str) -> &str {
|
|
||||||
match util_name {
|
|
||||||
"test" => "test_uu",
|
|
||||||
"test_uu" => "test",
|
|
||||||
x @ _ => x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn usage(cmap: &UtilityMap) {
|
fn usage(cmap: &UtilityMap) {
|
||||||
println!("{} {}", NAME, VERSION);
|
println!("{} {}", NAME, VERSION);
|
||||||
println!("");
|
println!("");
|
||||||
println!("Usage:");
|
println!("Usage:");
|
||||||
println!(" {} [util [arguments...]]\n", NAME);
|
println!(" {} [util [arguments...]]\n", NAME);
|
||||||
println!("Currently defined functions:");
|
println!("Currently defined functions:");
|
||||||
let mut utils: Vec<&str> = cmap.keys().map(|&s| name_sub(s)).collect();
|
let mut utils: Vec<&str> = cmap.keys().map(|&s| s).collect();
|
||||||
utils.sort();
|
utils.sort();
|
||||||
for util in utils.iter() {
|
for util in utils.iter() {
|
||||||
println!("\t{}", util);
|
println!("\t{}", util);
|
||||||
|
@ -72,7 +64,7 @@ fn main() {
|
||||||
args.remove(0);
|
args.remove(0);
|
||||||
let util = &args[0][..];
|
let util = &args[0][..];
|
||||||
|
|
||||||
match umap.get(name_sub(util)) {
|
match umap.get(util) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
std::process::exit(uumain(args.clone()));
|
std::process::exit(uumain(args.clone()));
|
||||||
}
|
}
|
||||||
|
@ -81,7 +73,7 @@ fn main() {
|
||||||
// see if they want help on a specific util
|
// see if they want help on a specific util
|
||||||
if args.len() >= 2 {
|
if args.len() >= 2 {
|
||||||
let util = &args[1][..];
|
let util = &args[1][..];
|
||||||
match umap.get(name_sub(util)) {
|
match umap.get(util) {
|
||||||
Some(&uumain) => {
|
Some(&uumain) => {
|
||||||
std::process::exit(uumain(vec![util.to_string(), "--help".to_string()]));
|
std::process::exit(uumain(vec![util.to_string(), "--help".to_string()]));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue