mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 18:28:18 +00:00
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
use crate::common::util::*;
|
|
use std::env;
|
|
|
|
#[test]
|
|
fn test_normal() {
|
|
let (_, mut ucmd) = at_and_ucmd!();
|
|
|
|
let result = ucmd.run();
|
|
println!("result.stdout = {}", result.stdout);
|
|
println!("result.stderr = {}", result.stderr);
|
|
println!("env::var(CI).is_ok() = {}", env::var("CI").is_ok());
|
|
|
|
for (key, value) in env::vars() {
|
|
println!("{}: {}", key, value);
|
|
}
|
|
if is_ci() && result.stderr.contains("failed to get username") {
|
|
// In the CI, some server are failing to return whoami.
|
|
// As seems to be a configuration issue, ignoring it
|
|
return;
|
|
}
|
|
|
|
assert!(result.success);
|
|
assert!(!result.stdout.trim().is_empty());
|
|
}
|
|
|
|
#[test]
|
|
#[cfg(not(windows))]
|
|
fn test_normal_compare_id() {
|
|
let (_, mut ucmd) = at_and_ucmd!();
|
|
|
|
let result = ucmd.run();
|
|
|
|
println!("result.stdout = {}", result.stdout);
|
|
println!("result.stderr = {}", result.stderr);
|
|
if is_ci() && result.stderr.contains("failed to get username") {
|
|
// In the CI, some server are failing to return whoami.
|
|
// As seems to be a configuration issue, ignoring it
|
|
return;
|
|
}
|
|
assert!(result.success);
|
|
let ts = TestScenario::new("id");
|
|
let id = ts.cmd("id").arg("-un").run();
|
|
|
|
if is_ci() && id.stderr.contains("cannot find name for user ID") {
|
|
// In the CI, some server are failing to return whoami.
|
|
// As seems to be a configuration issue, ignoring it
|
|
return;
|
|
}
|
|
assert_eq!(result.stdout.trim(), id.stdout.trim());
|
|
}
|