]> granicus.if.org Git - icu/commitdiff
ICU-9744 logKnownIssue and log_knownIssue for ICU4C
authorSteven R. Loomis <srl@icu-project.org>
Mon, 16 Sep 2013 22:07:02 +0000 (22:07 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Mon, 16 Sep 2013 22:07:02 +0000 (22:07 +0000)
X-SVN-Rev: 34335

icu4c/source/test/cintltst/cintltst.c
icu4c/source/test/cintltst/cintltst.h
icu4c/source/test/intltest/intltest.cpp
icu4c/source/test/intltest/intltest.h
icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/test/intltest/ssearch.cpp
icu4c/source/tools/ctestfw/ctest.c
icu4c/source/tools/ctestfw/unicode/ctest.h
icu4c/source/tools/toolutil/udbgutil.cpp
icu4c/source/tools/toolutil/udbgutil.h

index 24e1069ca139e0bf6c4ea99ab6c477bce26eee9d..de4007ae8b5a66313e7f262141a7fa9a2a0ff269 100644 (file)
@@ -696,6 +696,9 @@ U_CFUNC UBool assertEquals(const char* message, const char* expected,
  */
 
 U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) {
+  log_knownIssue("9744", "fix call to isICUVersionBefore()");
+  return TRUE;
+  /*
     UVersionInfo iv;
     UVersionInfo ov;
     ov[0] = (uint8_t)major;
@@ -704,10 +707,13 @@ U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) {
     ov[3] = 0;
     u_getVersion(iv);
     return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
+  */
 }
 
 U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli) {
-    return !isICUVersionBefore(major, minor, milli);
+  log_knownIssue("9744", "fix call to isICUVersionAtLeast()");
+  return FALSE;
+  //return !isICUVersionBefore(major, minor, milli);
 }
 
 #endif
index 6e6d1614f0abc9c725d01468ad0b64e3d0899167..6c7cf023dc19daa97c023fec2c32ed144f08e213 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -134,12 +134,15 @@ U_CFUNC UBool assertEquals(const char* msg, const char* expectedString,
 
 /**
  * Returns true if u_getVersion() < major.minor.milli.
+ * @deprecated use log_KnownIssue
  */
 U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli);
 
 /**
  * Returns true if u_getVersion() >= major.minor.milli.
+ * @deprecated use log_KnownIssue
  */
 U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli);
 
+
 #endif
index a918cadfa50ad9220ecc308506af621cfae79504..e8063835f1b9b2d8c8eb86bd685c31a77c33695a 100644 (file)
@@ -38,6 +38,7 @@
 #include "putilimp.h" // for uprv_getRawUTCtime()
 #include "unicode/locid.h"
 #include "unicode/ctest.h" // for str_timeDelta
+#include "udbgutil.h"
 
 #ifdef XP_MAC_CONSOLE
 #include <console.h>
@@ -49,6 +50,7 @@ static char* _testDataPath=NULL;
 
 // Static list of errors found
 static UnicodeString errorList;
+static UnicodeString knownList;
 
 //-----------------------------------------------------------------------------
 //convenience classes to ease porting code that uses the Java
@@ -547,6 +549,7 @@ IntlTest::IntlTest()
     LL_indentlevel = indentLevel_offset;
     numProps = 0;
     strcpy(basePath, "/");
+    currName[0]=0;
 }
 
 void IntlTest::setCaller( IntlTest* callingTest )
@@ -741,7 +744,9 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName )
             strcpy(saveBaseLoc,name);
             strcat(saveBaseLoc,"/");
 
+            strcpy(currName, name); // set
             this->runIndexedTest( index, TRUE, name, par );
+            currName[0]=0; // reset
 
             UDate timeStop = uprv_getRawUTCtime();
             rval = TRUE; // at least one test has been called
@@ -941,6 +946,37 @@ void IntlTest::logln(const char *fmt, ...)
     }
 }
 
+UBool IntlTest::logKnownIssue(const char *ticket, const char *fmt, ...)
+{
+    char buffer[4000];
+    va_list ap;
+
+    va_start(ap, fmt);
+    /* sprintf it just to make sure that the information is valid */
+    vsprintf(buffer, fmt, ap);
+    va_end(ap);
+    return logKnownIssue(ticket, UnicodeString(buffer, ""));
+}
+
+UBool IntlTest::logKnownIssue(const char *ticket) {
+  return logKnownIssue(ticket, UnicodeString());
+}
+
+UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) {
+  knownList.append(UnicodeString(ticket, ""));
+  knownList.append(UnicodeString(" ",""));
+  knownList.append(UnicodeString(basePath, ""));
+  knownList.append(UnicodeString(currName, ""));
+  knownList.append(UnicodeString(" ",""));
+  char URL[UDBG_KNOWNISSUE_LEN];
+  knownList.append(UnicodeString(udbg_knownIssueURLFrom(ticket, URL), ""));
+  knownList.append(UnicodeString(" ",""));
+  knownList.append(msg);
+  knownList.append(UnicodeString("\n", ""));
+
+  return true;
+}
+
 /* convenience functions that include sprintf formatting */
 void IntlTest::info(const char *fmt, ...)
 {
@@ -1020,6 +1056,17 @@ void IntlTest::printErrors()
      IntlTest::LL_message(errorList, TRUE);
 }
 
+UBool IntlTest::printKnownIssues()
+{
+  if(knownList.length()>0) {
+    IntlTest::LL_message( UnicodeString("KNOWN ISSUES:\n", ""), TRUE );
+    IntlTest::LL_message( knownList, TRUE );
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+
 void IntlTest::LL_message( UnicodeString message, UBool newline )
 {
     // string that starts with a LineFeed character and continues
@@ -1423,6 +1470,7 @@ main(int argc, char* argv[])
     }
 
     fprintf(stdout, "\n--------------------------------------\n");
+    major.printKnownIssues();
     if (major.getErrors() == 0) {
         /* Call it twice to make sure that the defaults were reset. */
         /* Call it before the OK message to verify proper cleanup. */
@@ -1908,7 +1956,13 @@ UBool IntlTest::isICUVersionBefore(int major, int minor, int milli) {
     UVersionInfo iv;
     UVersionInfo ov = { (uint8_t)major, (uint8_t)minor, (uint8_t)milli, 0 };
     u_getVersion(iv);
-    return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
+    logKnownIssue("9744", "fix call to isICUVersionBefore");
+    return TRUE;
+    if( uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0 ) {
+      return FALSE;
+    } else {
+      return FALSE;
+    }
 }
 
 #if !UCONFIG_NO_FORMATTING
index af630ccadf11f38e5f7666b21ef6a2ba2fe9c61f..b5d2a0c0f7662bf502b537bc946a42a9b1b66879 100644 (file)
@@ -156,6 +156,10 @@ public:
 
     virtual void logln( void );
 
+    UBool logKnownIssue( const char *ticket, const UnicodeString &message );
+    UBool logKnownIssue( const char *ticket );
+    UBool logKnownIssue( const char *ticket, const char *fmt, ...);
+
     virtual void info( const UnicodeString &message );
 
     virtual void infoln( const UnicodeString &message );
@@ -194,6 +198,9 @@ public:
 
     // Print ALL named errors encountered so far
     void printErrors(); 
+
+    // print known issues. return TRUE if there were any.
+    UBool printKnownIssues();
         
     virtual void usage( void ) ;
 
@@ -216,26 +223,26 @@ public:
     /**
      * Returns true if u_getVersion() < major.minor.
      */
-    static UBool isICUVersionBefore(int major, int minor) {
+    UBool isICUVersionBefore(int major, int minor) {
         return isICUVersionBefore(major, minor, 0);
     }
 
     /**
      * Returns true if u_getVersion() < major.minor.milli.
      */
-    static UBool isICUVersionBefore(int major, int minor, int milli);
+    UBool isICUVersionBefore(int major, int minor, int milli);
 
     /**
      * Returns true if u_getVersion() >= major.minor.
      */
-    static UBool isICUVersionAtLeast(int major, int minor) {
+    UBool isICUVersionAtLeast(int major, int minor) {
         return isICUVersionAtLeast(major, minor, 0);
     }
 
     /**
      * Returns true if u_getVersion() >= major.minor.milli.
      */
-    static UBool isICUVersionAtLeast(int major, int minor, int milli) {
+    UBool isICUVersionAtLeast(int major, int minor, int milli) {
         return !isICUVersionBefore(major, minor, milli);
     }
 
@@ -307,6 +314,7 @@ private:
     char*       testPath;           // specifies subtests
     
     char basePath[1024];
+    char currName[1024]; // current test name
 
     //FILE *testoutfp;
     void *testoutfp;
index 51cd6d3757c6fbe1ba0e2ebdd4a195849b800f61..95bf8dde4df9fd75edfda691e6c79d82ec496fff 100644 (file)
@@ -1570,7 +1570,7 @@ void RBBITest::TestUnicodeFiles() {
 void RBBITest::runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi) {
 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
     // TODO(andy): Match line break behavior to Unicode 6.0 and remove this time bomb. Ticket #7270
-    UBool isTicket7270Fixed = isICUVersionAtLeast(52, 1);
+    UBool isTicket7270Fixed = !logKnownIssue("7270");
     UBool isLineBreak = 0 == strcmp(fileName, "LineBreakTest.txt");
     UErrorCode  status = U_ZERO_ERROR;
 
index 64b1fe659a92e71fe3f9c04806e8dc25cd3c92c1..fbbbd86e4eb95bb9c065eda36edf37a6f22a1a1b 100644 (file)
@@ -629,7 +629,7 @@ void SSearchTest::offsetTest()
     col->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
 
     for(int32_t i = 0; i < testCount; i += 1) {
-        if (!isICUVersionAtLeast(52, 0, 2) && i>=4 && i<=6) {
+      if (i>=4 && i<=6 && logKnownIssue("9156")) {
             continue; // timebomb until ticket #9156 (was #8081) is resolved
         }
         UnicodeString ts = CharsToUnicodeString(test[i]);
index 59995ff7a3217a1847dbe00d430c52c33a01ecdd..45cc8632c612f8ef58b9b96a63fba7e5469d5bee 100644 (file)
@@ -88,6 +88,7 @@ static void help ( const char *argv0 );
  */
 static void vlog_err(const char *prefix, const char *pattern, va_list ap);
 static void vlog_verbose(const char *prefix, const char *pattern, va_list ap);
+static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap);
 
 /**
  * Log test structure, with indent
@@ -679,6 +680,30 @@ static void vlog_err(const char *prefix, const char *pattern, va_list ap)
     GLOBAL_PRINT_COUNT++;
 }
 
+static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap)
+{
+    /* fputs("!", stdout); /\* col 1 - bang *\/ */
+    /* fprintf(stdout, "%-*s", INDENT_LEVEL,"" ); */
+    /* if(prefix) { */
+    /*     fputs(prefix, stdout); */
+    /* } */
+    char buf[2048], url[1024];
+    vsprintf(buf, pattern, ap);
+
+    printf("KNOWN ISSUE: #%s %s\n", ticket, buf);
+
+    /* fflush(stdout); */
+    /* va_end(ap); */
+    /* if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) { */
+    /*         HANGING_OUTPUT=1; */
+    /* } else { */
+    /*         HANGING_OUTPUT=0; */
+    /* } */
+    /* GLOBAL_PRINT_COUNT++; */
+    return TRUE;
+}
+
+
 void T_CTEST_EXPORT2
 vlog_info(const char *prefix, const char *pattern, va_list ap)
 {
@@ -766,6 +791,13 @@ log_err(const char* pattern, ...)
     vlog_err(NULL, pattern, ap);
 }
 
+UBool T_CTEST_EXPORT2
+log_knownIssue(const char *ticket, const char *pattern, ...) {
+  va_list ap;
+  va_start(ap, pattern);
+  return vlog_knownIssue(ticket, pattern, ap);
+}
+
 void T_CTEST_EXPORT2
 log_err_status(UErrorCode status, const char* pattern, ...)
 {
index bbff5a0bef45f405f7868b0908f7f8b0761d0a60..97f4289de9688440a1a3d69b67f4d74d8c14e1e2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  ********************************************************************************
  *
- *   Copyright (C) 1996-2010, International Business Machines
+ *   Copyright (C) 1996-2013, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  ********************************************************************************
@@ -299,4 +299,15 @@ T_CTEST_API int32_t
 T_CTEST_EXPORT2
 ctest_xml_testcase(const char *classname, const char *name, const char *time, const char *failMsg);
 
+
+/**
+ * Log a known issue.
+ * @param ticket ticket number such as "12345" for ICU tickets or "cldr:6636" for CLDR tickets.
+ * @param fmt ...  sprintf-style format, optional message. can be NULL.
+ * @return TRUE unless known issues should be tested
+ */
+T_CTEST_API UBool
+T_CTEST_EXPORT2
+log_knownIssue(const char *ticket, const char *fmt, ...);
+
 #endif
index 46c14c05779c8a4acbb5202130a243e187e302f9..945828ec5de47198e5894976ef42d349acc10e43 100644 (file)
@@ -580,3 +580,22 @@ U_CAPI void udbg_writeIcuInfo(FILE *out) {
   }
   fprintf(out, " </icuSystemParams>\n");
 }
+
+#define ICU_TRAC_URL "http://bugs.icu-project.org/trac/ticket/"
+#define CLDR_TRAC_URL "http://unicode.org/cldr/trac/ticket/"
+#define CLDR_TICKET_PREFIX "cldrbug:"
+
+U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf) {
+  if( ticket==NULL ) {
+    return NULL;
+  }
+
+  if( !strncmp(ticket, CLDR_TICKET_PREFIX, strlen(CLDR_TICKET_PREFIX)) ) {
+    strcpy( buf, CLDR_TRAC_URL );
+    strcat( buf, ticket+strlen(CLDR_TICKET_PREFIX) );
+  } else {
+    strcpy( buf, ICU_TRAC_URL );
+    strcat( buf, ticket );
+  }
+  return buf;
+}
index 0f4da6cbd7fdb7615a4effa73888ab42a1954f92..dec4d5b2f9fd84226865719c065167e6afc13d94 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ************************************************************************
-* Copyright (c) 2008-2011, International Business Machines
+* Copyright (c) 2008-2013, International Business Machines
 * Corporation and others.  All Rights Reserved.
 ************************************************************************
 */
@@ -103,4 +103,18 @@ U_CAPI int32_t udbg_getSystemParameterValueByIndex(int32_t i, char *buffer, int3
  */
 U_CAPI void udbg_writeIcuInfo(FILE *f);
 
+/**
+ * \def UDBG_KNOWNISSUE_LEN
+ * Length of output buffer for udbg_knownIssueURLFrom
+ */
+#define UDBG_KNOWNISSUE_LEN 255
+
+/**
+ * Convert a "known issue" string into a URL
+ * @param ticket ticket string such as "10245" or "cldrbug:5013"
+ * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size
+ * @return pointer to output buffer, or NULL on err
+ */
+U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf);
+
 #endif