diff --git a/tests/by-util/test_groups.rs b/tests/by-util/test_groups.rs index 8d120f266..6bad2f523 100644 --- a/tests/by-util/test_groups.rs +++ b/tests/by-util/test_groups.rs @@ -7,10 +7,7 @@ fn test_groups() { let result = ucmd.run(); println!("result.stdout {}", result.stdout); println!("result.stderr = {}", result.stderr); - if env::var("USER").is_ok() - && env::var("USER").unwrap() == "runner" - && result.stdout.trim().is_empty() - { + if is_ci() && result.stdout.trim().is_empty() { // In the CI, some server are failing to return the group. // As seems to be a configuration issue, ignoring it return; @@ -26,7 +23,7 @@ fn test_groups_arg() { println!("result.stdout {}", result.stdout); println!("result.stderr = {}", result.stderr); let s1 = String::from(result.stdout.trim()); - if s1.parse::().is_ok() { + if is_ci() && s1.parse::().is_ok() { // In the CI, some server are failing to return id -un. // So, if we are getting a uid, just skip this test // As seems to be a configuration issue, ignoring it diff --git a/tests/by-util/test_id.rs b/tests/by-util/test_id.rs index 822c49560..0541a2a89 100644 --- a/tests/by-util/test_id.rs +++ b/tests/by-util/test_id.rs @@ -14,7 +14,7 @@ fn test_id() { let uid = String::from(result.stdout.trim()); 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. // As seems to be a configuration issue, ignoring it return; @@ -31,7 +31,7 @@ fn test_id() { fn test_id_from_name() { let mut scene = TestScenario::new("whoami"); 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. // As seems to be a configuration issue, ignoring it return; @@ -65,7 +65,7 @@ fn test_id_name_from_id() { scene = TestScenario::new(util_name!()); 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. // As seems to be a configuration issue, ignoring it return; diff --git a/tests/by-util/test_logname.rs b/tests/by-util/test_logname.rs index 00c98c256..8dea3ee8b 100644 --- a/tests/by-util/test_logname.rs +++ b/tests/by-util/test_logname.rs @@ -13,10 +13,7 @@ fn test_normal() { for (key, value) in env::vars() { println!("{}: {}", key, value); } - if env::var("USER").is_ok() - && env::var("USER").unwrap() == "runner" - && result.stderr.contains("error: no login name") - { + if is_ci() && result.stderr.contains("error: no login name") { // In the CI, some server are failing to return logname. // As seems to be a configuration issue, ignoring it return; diff --git a/tests/by-util/test_whoami.rs b/tests/by-util/test_whoami.rs index 2c64bb067..c6ec6990f 100644 --- a/tests/by-util/test_whoami.rs +++ b/tests/by-util/test_whoami.rs @@ -13,10 +13,7 @@ fn test_normal() { for (key, value) in env::vars() { println!("{}: {}", key, value); } - if env::var("USER").is_ok() - && env::var("USER").unwrap() == "runner" - && result.stderr.contains("failed to get username") - { + 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; @@ -35,10 +32,7 @@ fn test_normal_compare_id() { println!("result.stdout = {}", result.stdout); println!("result.stderr = {}", result.stderr); - if env::var("USER").is_ok() - && env::var("USER").unwrap() == "runner" - && result.stderr.contains("failed to get username") - { + 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; @@ -47,10 +41,7 @@ fn test_normal_compare_id() { let ts = TestScenario::new("id"); let id = ts.cmd("id").arg("-un").run(); - if env::var("USER").is_ok() - && env::var("USER").unwrap() == "runner" - && id.stderr.contains("cannot find name for user ID") - { + 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;