1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tests/refactor ~ use is_ci() for CI host platform testing

This commit is contained in:
Roy Ivy III 2020-06-13 21:51:59 -05:00
parent 407d455b12
commit d144182add
4 changed files with 9 additions and 24 deletions

View file

@ -7,10 +7,7 @@ fn test_groups() {
let result = ucmd.run(); let result = ucmd.run();
println!("result.stdout {}", result.stdout); println!("result.stdout {}", result.stdout);
println!("result.stderr = {}", result.stderr); println!("result.stderr = {}", result.stderr);
if env::var("USER").is_ok() if is_ci() && result.stdout.trim().is_empty() {
&& env::var("USER").unwrap() == "runner"
&& result.stdout.trim().is_empty()
{
// In the CI, some server are failing to return the group. // In the CI, some server are failing to return the group.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -26,7 +23,7 @@ fn test_groups_arg() {
println!("result.stdout {}", result.stdout); println!("result.stdout {}", result.stdout);
println!("result.stderr = {}", result.stderr); println!("result.stderr = {}", result.stderr);
let s1 = String::from(result.stdout.trim()); let s1 = String::from(result.stdout.trim());
if s1.parse::<f64>().is_ok() { if is_ci() && s1.parse::<f64>().is_ok() {
// In the CI, some server are failing to return id -un. // In the CI, some server are failing to return id -un.
// So, if we are getting a uid, just skip this test // So, if we are getting a uid, just skip this test
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it

View file

@ -14,7 +14,7 @@ fn test_id() {
let uid = String::from(result.stdout.trim()); let uid = String::from(result.stdout.trim());
result = scene.ucmd().run(); result = scene.ucmd().run();
if result.stderr.contains("cannot find name for user ID") { if is_ci() && result.stderr.contains("cannot find name for user ID") {
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -31,7 +31,7 @@ fn test_id() {
fn test_id_from_name() { fn test_id_from_name() {
let mut scene = TestScenario::new("whoami"); let mut scene = TestScenario::new("whoami");
let result = scene.cmd("whoami").run(); let result = scene.cmd("whoami").run();
if result.stderr.contains("cannot find name for user ID") { if is_ci() && result.stderr.contains("cannot find name for user ID") {
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -65,7 +65,7 @@ fn test_id_name_from_id() {
scene = TestScenario::new(util_name!()); scene = TestScenario::new(util_name!());
let result = scene.ucmd().arg("-nu").arg(uid).run(); let result = scene.ucmd().arg("-nu").arg(uid).run();
if result.stderr.contains("No such user/group") { if is_ci() && result.stderr.contains("No such user/group") {
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;

View file

@ -13,10 +13,7 @@ fn test_normal() {
for (key, value) in env::vars() { for (key, value) in env::vars() {
println!("{}: {}", key, value); println!("{}: {}", key, value);
} }
if env::var("USER").is_ok() if is_ci() && result.stderr.contains("error: no login name") {
&& env::var("USER").unwrap() == "runner"
&& result.stderr.contains("error: no login name")
{
// In the CI, some server are failing to return logname. // In the CI, some server are failing to return logname.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;

View file

@ -13,10 +13,7 @@ fn test_normal() {
for (key, value) in env::vars() { for (key, value) in env::vars() {
println!("{}: {}", key, value); println!("{}: {}", key, value);
} }
if env::var("USER").is_ok() if is_ci() && result.stderr.contains("failed to get username") {
&& env::var("USER").unwrap() == "runner"
&& result.stderr.contains("failed to get username")
{
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -35,10 +32,7 @@ fn test_normal_compare_id() {
println!("result.stdout = {}", result.stdout); println!("result.stdout = {}", result.stdout);
println!("result.stderr = {}", result.stderr); println!("result.stderr = {}", result.stderr);
if env::var("USER").is_ok() if is_ci() && result.stderr.contains("failed to get username") {
&& env::var("USER").unwrap() == "runner"
&& result.stderr.contains("failed to get username")
{
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;
@ -47,10 +41,7 @@ fn test_normal_compare_id() {
let ts = TestScenario::new("id"); let ts = TestScenario::new("id");
let id = ts.cmd("id").arg("-un").run(); let id = ts.cmd("id").arg("-un").run();
if env::var("USER").is_ok() if is_ci() && id.stderr.contains("cannot find name for user ID") {
&& env::var("USER").unwrap() == "runner"
&& id.stderr.contains("cannot find name for user ID")
{
// In the CI, some server are failing to return whoami. // In the CI, some server are failing to return whoami.
// As seems to be a configuration issue, ignoring it // As seems to be a configuration issue, ignoring it
return; return;