@@ -13,6 +13,8 @@ use regex::Regex;
1313#[ cfg( all( unix, not( target_os = "macos" ) ) ) ]
1414use uucore:: process:: geteuid;
1515use uutests:: util:: TestScenario ;
16+ #[ cfg( unix) ]
17+ use uutests:: util:: is_locale_available;
1618use uutests:: { at_and_ucmd, new_ucmd, util_name} ;
1719
1820#[ test]
@@ -1840,20 +1842,7 @@ fn test_date_parenthesis_vs_other_special_chars() {
18401842fn test_date_iranian_locale_solar_hijri_calendar ( ) {
18411843 // Test Iranian locale uses Solar Hijri calendar
18421844 // Verify the Solar Hijri calendar is used in the Iranian locale
1843- use std:: process:: Command ;
1844-
1845- // Check if Iranian locale is available
1846- let locale_check = Command :: new ( "locale" )
1847- . env ( "LC_ALL" , "fa_IR.UTF-8" )
1848- . arg ( "charmap" )
1849- . output ( ) ;
1850-
1851- let locale_available = match locale_check {
1852- Ok ( output) => String :: from_utf8_lossy ( & output. stdout ) . trim ( ) == "UTF-8" ,
1853- Err ( _) => false ,
1854- } ;
1855-
1856- if !locale_available {
1845+ if !is_locale_available ( "fa_IR.UTF-8" ) {
18571846 println ! ( "Skipping Iranian locale test - fa_IR.UTF-8 locale not available" ) ;
18581847 return ;
18591848 }
@@ -1920,20 +1909,7 @@ fn test_date_iranian_locale_solar_hijri_calendar() {
19201909fn test_date_ethiopian_locale_calendar ( ) {
19211910 // Test Ethiopian locale uses Ethiopian calendar
19221911 // Verify the Ethiopian calendar is used in the Ethiopian locale
1923- use std:: process:: Command ;
1924-
1925- // Check if Ethiopian locale is available
1926- let locale_check = Command :: new ( "locale" )
1927- . env ( "LC_ALL" , "am_ET.UTF-8" )
1928- . arg ( "charmap" )
1929- . output ( ) ;
1930-
1931- let locale_available = match locale_check {
1932- Ok ( output) => String :: from_utf8_lossy ( & output. stdout ) . trim ( ) == "UTF-8" ,
1933- Err ( _) => false ,
1934- } ;
1935-
1936- if !locale_available {
1912+ if !is_locale_available ( "am_ET.UTF-8" ) {
19371913 println ! ( "Skipping Ethiopian locale test - am_ET.UTF-8 locale not available" ) ;
19381914 return ;
19391915 }
@@ -2000,20 +1976,7 @@ fn test_date_ethiopian_locale_calendar() {
20001976fn test_date_thai_locale_solar_calendar ( ) {
20011977 // Test Thai locale uses Thai solar calendar
20021978 // Verify the Thai solar calendar is used with the Thai locale
2003- use std:: process:: Command ;
2004-
2005- // Check if Thai locale is available
2006- let locale_check = Command :: new ( "locale" )
2007- . env ( "LC_ALL" , "th_TH.UTF-8" )
2008- . arg ( "charmap" )
2009- . output ( ) ;
2010-
2011- let locale_available = match locale_check {
2012- Ok ( output) => String :: from_utf8_lossy ( & output. stdout ) . trim ( ) == "UTF-8" ,
2013- Err ( _) => false ,
2014- } ;
2015-
2016- if !locale_available {
1979+ if !is_locale_available ( "th_TH.UTF-8" ) {
20171980 println ! ( "Skipping Thai locale test - th_TH.UTF-8 locale not available" ) ;
20181981 return ;
20191982 }
0 commit comments