2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2020-05-15 12:19:40 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-06-14 02:51:59 +00:00
|
|
|
if is_ci() && result.stderr.contains("failed to get username") {
|
2020-05-15 12:19:40 +00:00
|
|
|
// 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]
|
2020-05-27 07:30:23 +00:00
|
|
|
#[cfg(not(windows))]
|
2020-05-15 12:19:40 +00:00
|
|
|
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);
|
2020-06-14 02:51:59 +00:00
|
|
|
if is_ci() && result.stderr.contains("failed to get username") {
|
2020-05-15 12:19:40 +00:00
|
|
|
// 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();
|
|
|
|
|
2020-06-14 02:51:59 +00:00
|
|
|
if is_ci() && id.stderr.contains("cannot find name for user ID") {
|
2020-05-15 12:19:40 +00:00
|
|
|
// 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());
|
|
|
|
}
|