]> granicus.if.org Git - icu/commitdiff
ICU-22262 Automate environment test
authorFrank Yung-Fong Tang <ftang@google.com>
Mon, 13 Feb 2023 22:27:25 +0000 (22:27 +0000)
committerFrank Yung-Fong Tang <ftang@google.com>
Wed, 15 Feb 2023 23:24:19 +0000 (15:24 -0800)
See #2309

.github/workflows/icu_envtest.yml [new file with mode: 0644]
icu4c/source/test/cintltst/cdtrgtst.c
icu4c/source/test/cintltst/cloctst.c
icu4c/source/test/intltest/itercoll.cpp
icu4c/source/test/intltest/loctest.cpp
icu4c/source/test/intltest/tztest.cpp

diff --git a/.github/workflows/icu_envtest.yml b/.github/workflows/icu_envtest.yml
new file mode 100644 (file)
index 0000000..ed8a0a8
--- /dev/null
@@ -0,0 +1,136 @@
+# Copyright (C) 2023 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+#
+# GitHub Action configuration script for ICU environment test tasks.
+#
+
+name: GHA EnvTest
+
+on:
+  workflow_dispatch:
+    # To trigger the Env Test workflow manually, follow the instructions in
+    # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
+
+  schedule:
+    # This cron schedule is set to run 10:23 UTC every SAT
+    - cron: '23 10 * * SAT'
+
+jobs:
+  #=================================================================
+  # locale env tests.
+  env-test-locale:
+    runs-on: ubuntu-latest
+    strategy:
+      # "fail-fast: false" let other jobs keep running even if the test break in some locales.
+      fail-fast: false
+      matrix:
+        # Since we have total 500+ locales to run on three set of test, we create
+        # many jobs to test concurrently.
+        # shard is used to bucket the lines from the locale list into jobs.
+        # Currently we run testing of 30 locales per shard, and we have total 17 shards.
+        # 17x30 = 510 > 502 (the number of locales in 'locale -a').
+        tests_per_shard: [30]
+        shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
+    steps:
+      - name: Install all locales by apt-get
+        run: |
+          sudo apt-get update -y;
+          sudo apt-get install -y locales-all;
+      - name: Show installed locales post apt-get
+        run: |
+          locale -a;
+      - name: Checkout and setup
+        uses: actions/checkout@v2
+      - name: Build
+        run: |
+          cd icu4c/source/;
+          ./runConfigureICU Linux;
+          make -j10 tests;
+      - name: Test different locales as LC_ALL
+        run: |
+          echo "This job run the environment test of the following Locales";
+          begin=$(( ${{matrix.shard}} * ${{matrix.tests_per_shard}} + 1));
+          end=$(( (${{matrix.shard}}+1) * ${{matrix.tests_per_shard}} ));
+          sedarg=${begin},${end}p;
+          locale -a |sed -n ${sedarg};
+
+          cd icu4c/source/test;
+          for loc in `locale -a |sed -n ${sedarg}`;
+          do
+              echo "============================================";
+              echo "Start Tests under LC_ALL=$loc locale";
+              for test_dir in iotest cintltst intltest
+              do
+                  cd $test_dir;
+                  LC_ALL=$loc make check;
+                  cd ..;
+              done
+
+              echo "Complete Tests under LC_ALL=$loc locale";
+              echo "============================================";
+          done
+
+          echo "This job completed the test of the following Locales";
+          locale -a |sed -n ${sedarg};
+
+  #=================================================================
+  # tz env tests.
+  env-test-tz:
+    runs-on: ubuntu-latest
+    strategy:
+      # "fail-fast: false" let other jobs keep running even if the test break in some timezones.
+      fail-fast: false
+      matrix:
+        # Since we have total 600+ timezones to run on three set of test, we create
+        # many jobs to test concurrently.
+        # shard is used to bucket the lines from the timezone list into jobs.
+        # Currently we run testing of 30 timezones per shard, and we have total 21 shards.
+        # 21x30 = 630 > 604 (the number of known timezones).
+        tests_per_shard: [30]
+        shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
+    steps:
+      - name: Install all locales by apt-get
+        run: |
+          sudo apt-get update -y;
+          sudo apt-get install -y tzdata;
+      - name: Show all the TimeZones
+        run: |
+          echo "Total number of TimeZone is "
+          find /usr/share/zoneinfo/ -type f,l|egrep -v "/(right|posix)/"|egrep -v "\.tab"|wc -l;
+          find /usr/share/zoneinfo/ -type f,l|egrep -v "/(right|posix)/"|egrep -v "\.tab"|cut -d '/' -f5-50;
+      - name: Checkout and setup
+        uses: actions/checkout@v2
+      - name: Build
+        run: |
+          cd icu4c/source/;
+          ./runConfigureICU Linux;
+          make -j10 tests;
+      - name: Test different locales as TZ
+        run: |
+          echo "This job run the environment test of the following TimeZones";
+          begin=$(( ${{matrix.shard}} * ${{matrix.tests_per_shard}} + 1));
+          end=$(( (${{matrix.shard}}+1) * ${{matrix.tests_per_shard}} ));
+          sedarg=${begin},${end}p;
+          find /usr/share/zoneinfo/ -type f,l|egrep -v "/(right|posix)/"|egrep -v "\.tab"|sed -n ${sedarg}|cut -d '/' -f5-50;
+
+          cd icu4c/source/test;
+          for tz in `find /usr/share/zoneinfo/ -type f,l|egrep -v "/(right|posix)/"|egrep -v "\.tab"|sed -n ${sedarg}|cut -d '/' -f5-50`;
+
+          do
+              echo "============================================";
+              echo "Start Tests under TZ=$tz TimeZone";
+              for test_dir in iotest cintltst intltest
+              do
+                  cd $test_dir;
+                  TZ=$tz make check;
+                  cd ..;
+              done
+
+              echo "Complete Tests under TZ=$tz TimeZone";
+              echo "============================================";
+          done
+
+          echo "This job completed the test of the following TimeZones";
+          find /usr/share/zoneinfo/ -type f,l|egrep -v "/(right|posix)/"|egrep -v "\.tab"|sed -n ${sedarg}|cut -d '/' -f5-50;
+
+  #=================================================================
index dc45fa2902a4a9606ab9999aecfadcd6c92c09b1..5ee21e294abbeaf3bee04b34fb61f412b306bcb3 100644 (file)
 #include "unicode/uloc.h"
 #include "unicode/udat.h"
 #include "unicode/ucal.h"
+#include "unicode/uchar.h"
 #include "unicode/unum.h"
 #include "unicode/ustring.h"
+#include "unicode/utf16.h"
 #include "cintltst.h"
 #include "cdtrgtst.h"
 #include "cmemory.h"
@@ -190,8 +192,12 @@ void Test4056591()
             log_err("myFormatit failed!\n");
         }
         else if(u_strcmp(gotdate, expdate) !=0){
-            log_err("set2DigitYearStart broken for %s \n  got: %s, expected: %s\n", austrdup(s),
-                austrdup(gotdate), austrdup(expdate) );
+            if (strcmp("gregorian", ucal_getType(udat_getCalendar(def), &status)) == 0) {
+                // Only report error if the calendar is gregorian because the
+                // expectation is only for gregorian.
+                log_err("set2DigitYearStart broken for %s \n  got: %s, expected: %s\n", austrdup(s),
+                    austrdup(gotdate), austrdup(expdate) );
+            }
         }
     }
     
@@ -241,6 +247,30 @@ void Test4059917()
     free(myDate);
 }
 
+UBool EqualIgnoreNumberingSystem(UChar* a, UChar* b);
+// This function return true if the sting contains the same value or the
+// numerical values are the same if we ignore the numbering system.
+UBool EqualIgnoreNumberingSystem(UChar* a, UChar* b) {
+    // len1 and len2 may not be the same if one of them are numeric outside BMP.
+    int32_t len1 = u_strlen(a);
+    int32_t len2 = u_strlen(b);
+    UChar32 ch1, ch2;
+    int32_t idx1, idx2;
+    idx1=idx2=0;
+    // U16_NEXT will increment idx1 and idx2 inside the loop.
+    while (idx1 < len1 && idx2 < len2) {
+        U16_NEXT(a, idx1, len1, ch1);
+        U16_NEXT(b, idx2, len2, ch2);
+        if (ch1 != ch2) {
+            int32_t digit1 = u_charDigitValue(ch1);
+            int32_t digit2 = u_charDigitValue(ch2);
+            if (digit1 < 0 || digit1 != digit2) { return false; }
+        }
+    }
+    // only return true if both reach end of the string.
+    return idx1 == len1 && idx2 == len2;
+}
+
 void aux917( UDateFormat *fmt, UChar* str) 
 {    
     int32_t resultlength, resultlengthneeded;
@@ -266,7 +296,14 @@ void aux917( UDateFormat *fmt, UChar* str)
     status = U_ZERO_ERROR;
     formatted = myFormatit(fmt, d1);
     if( u_strcmp(formatted,str)!=0) {
-        log_err("Fail: Want %s Got: %s\n", austrdup(str),  austrdup(formatted) );
+        // We may get non-ASCII result back for some locale such as ne_NP
+        // which use numbering systems other than latn
+        if (strcmp("gregorian", ucal_getType(udat_getCalendar(fmt), &status)) != 0) {
+          log_verbose("Skipping Test4059917 when the default date time format is not using gregorian calendar.");
+
+        } else if (!EqualIgnoreNumberingSystem(formatted,str)) {
+          log_err("Fail: Want %s Got: %s\n", austrdup(str),  austrdup(formatted) );
+        }
     }
     free(pat);
 }
index 1bb35444a4d8a925cb528b8ae51417abb8ab5d1f..a4a40dc4972ce7b149ab8b54a48d18fe4aeda208 100644 (file)
@@ -7219,6 +7219,10 @@ static void TestCDefaultLocale() {
       log_verbose("Skipping TestCDefaultLocale test, as the LANG variable is not set.");
       return;
     }
+    if (getenv("LC_ALL") != NULL) {
+      log_verbose("Skipping TestCDefaultLocale test, as the LC_ALL variable is set.");
+      return;
+    }
     if ((strcmp(env_var, "C") == 0 || strcmp(env_var, "C.UTF-8") == 0) && strcmp(defaultLocale, "en_US_POSIX") != 0) {
       log_err("The default locale for LANG=%s should be en_US_POSIX, not %s\n", env_var, defaultLocale);
     }
index 5c41ac963ea3232f9a3232d0eade378bef3b39f1..7a349bda76ad152da8e3d468cf551bfc39dcfef2 100644 (file)
@@ -488,22 +488,23 @@ void CollationIteratorTest::TestAssignment()
     CollationElementIterator *iter4 
                         = coll->createCollationElementIterator(source);
     CollationElementIterator iter5(*iter4);
+    int32_t order4, order5;
     if (*iter4 != iter5) {
         errln("collation iterator assignment does not produce the same elements");
     }
-    iter4->next(status);
+    order4 = iter4->next(status);
     if (U_FAILURE(status) || *iter4 == iter5) {
         errln("collation iterator not equal");
     }
-    iter5.next(status);
+    order5 = iter5.next(status);
     if (U_FAILURE(status) || *iter4 != iter5) {
         errln("collation iterator equal");
     }
-    iter4->next(status);
+    order4 = iter4->next(status);
     if (U_FAILURE(status) || *iter4 == iter5) {
         errln("collation iterator not equal");
     }
-    iter5.next(status);
+    order5 = iter5.next(status);
     if (U_FAILURE(status) || *iter4 != iter5) {
         errln("collation iterator equal");
     }
@@ -511,21 +512,24 @@ void CollationIteratorTest::TestAssignment()
     if (*iter4 != iter6) {
         errln("collation iterator equal");
     }
-    iter4->next(status);
+    order4 = iter4->next(status);
     if (U_FAILURE(status) || *iter4 == iter5) {
         errln("collation iterator not equal");
     }
-    iter5.next(status);
+    order5 = iter5.next(status);
     if (U_FAILURE(status) || *iter4 != iter5) {
         errln("collation iterator equal");
     }
-    iter4->next(status);
-    if (U_FAILURE(status) || *iter4 == iter5) {
-        errln("collation iterator not equal");
-    }
-    iter5.next(status);
-    if (U_FAILURE(status) || *iter4 != iter5) {
-        errln("collation iterator equal");
+    if (!(order4 == CollationElementIterator::NULLORDER &&
+          order5 == CollationElementIterator::NULLORDER)) {
+        order4 = iter4->next(status);
+        if (U_FAILURE(status) || *iter4 == iter5) {
+            errln("collation iterator not equal");
+        }
+        order5 = iter5.next(status);
+        if (U_FAILURE(status) || *iter4 != iter5) {
+            errln("collation iterator equal");
+        }
     }
     delete iter1;
     delete iter4;
index 8c2c64702268586c06a72934be17598077561a03..540ae8e77cac60143442f7076176a0f349e364d4 100644 (file)
@@ -1407,13 +1407,15 @@ LocaleTest::Test4139940()
     // o double acute (\u0151) IS.
     char16_t ocf = 0x00f4;
     char16_t oda = 0x0151;
+
     if (str.indexOf(oda) < 0 || str.indexOf(ocf) >= 0) {
-      /* If the default locale is "th" this test will fail because of the buddhist calendar. */
-      if (strcmp(Locale::getDefault().getLanguage(), "th") != 0) {
+      /* If the default calendar of the default locale is not "gregorian" this test will fail. */
+      LocalPointer<Calendar> defaultCalendar(Calendar::createInstance(status));
+      if (strcmp(defaultCalendar->getType(), "gregorian") == 0) {
         errln("Fail: Monday in Hungarian is wrong - oda's index is %d and ocf's is %d",
               str.indexOf(oda), str.indexOf(ocf));
       } else {
-        logln(UnicodeString("An error is produce in buddhist calendar."));
+        logln(UnicodeString("An error is produce in non Gregorian calendar."));
       }
       logln(UnicodeString("String is: ") + str );
     }
index eebe71815b7fa4a1ffc0e71c20194ef1dd8097db..425f8d6daa3aa1a7698821c5c7d558dedf7f1baa 100644 (file)
@@ -147,7 +147,17 @@ TimeZoneTest::TestGenericAPI()
 
     /* Host time zone's offset should match the offset returned by uprv_timezone() */
     if (hostZoneRawOffset != tzoffset * (-1000)) {
-        errln("FAIL: detectHostTimeZone()'s raw offset != host timezone's offset");
+        UnicodeString id;
+        hostZone->getID(id);
+        // Known issues in ICU-22274 we have issues in time zone
+        // Africa/Casablanca Europe/Dublin America/Godthab America/Nuuk
+        if (id == u"Africa/Casablanca" || id == u"Europe/Dublin" ||
+            id == u"America/Godthab" || id == u"America/Nuuk" ||
+            id == u"Africa/El_Aaiun") {
+          logKnownIssue( "ICU-22274", "detectHostTimeZone()'s raw offset != host timezone's offset in TimeZone " + id);
+        } else {
+          errln("FAIL: detectHostTimeZone()'s raw offset != host timezone's offset");
+        }
     }
     delete hostZone;