2021-07-07 22:21:28 +00:00
|
|
|
// * This file is part of the uutils coreutils package.
|
|
|
|
// *
|
|
|
|
// * For the full copyright and license information, please view the LICENSE
|
|
|
|
// * file that was distributed with this source code.
|
2021-04-17 20:29:07 +00:00
|
|
|
|
2021-07-07 22:21:28 +00:00
|
|
|
use crate::common::util::*;
|
2020-05-15 12:19:40 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-07-07 22:21:28 +00:00
|
|
|
#[cfg(unix)]
|
2020-05-15 12:19:40 +00:00
|
|
|
fn test_normal() {
|
2021-07-07 22:21:28 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let result = ts.ucmd().run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
|
|
|
|
|
|
|
result
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2020-05-15 12:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-07 22:21:28 +00:00
|
|
|
#[cfg(unix)]
|
2020-05-15 12:19:40 +00:00
|
|
|
fn test_normal_compare_id() {
|
2021-07-07 22:21:28 +00:00
|
|
|
let ts = TestScenario::new("id");
|
|
|
|
let id_un = unwrap_or_return!(expected_result(&ts, &["-un"]));
|
|
|
|
if id_un.succeeded() {
|
|
|
|
new_ucmd!().succeeds().stdout_is(id_un.stdout_str());
|
|
|
|
} else if is_ci() && id_un.stderr_str().contains("cannot find name for user ID") {
|
|
|
|
println!("test skipped:");
|
|
|
|
} else {
|
|
|
|
id_un.success();
|
2020-05-15 12:19:40 +00:00
|
|
|
}
|
2021-07-07 22:21:28 +00:00
|
|
|
}
|
2020-05-15 12:19:40 +00:00
|
|
|
|
2021-07-07 22:21:28 +00:00
|
|
|
#[test]
|
|
|
|
fn test_normal_compare_env() {
|
|
|
|
let whoami = whoami();
|
|
|
|
if whoami == "nobody" {
|
|
|
|
println!("test skipped:");
|
2021-07-07 23:32:39 +00:00
|
|
|
} else if !is_ci() {
|
2021-07-07 22:21:28 +00:00
|
|
|
new_ucmd!().succeeds().stdout_is(format!("{}\n", whoami));
|
2021-07-07 23:32:39 +00:00
|
|
|
} else {
|
|
|
|
println!("test skipped:");
|
2020-05-15 12:19:40 +00:00
|
|
|
}
|
|
|
|
}
|