From 4231ca5be053a22a1be24eb891817458c97db709 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 20 May 2020 13:29:35 -0700 Subject: [PATCH] ICU-21098 fix ticket URLs for logKnownIssue tickets. - Still allows "1234" or "cldrbug:1234" format ticket IDs - However, docs recommend "ICU-1234" or "CLDR-1234" format in the future. - Other ticket IDs could be used, but won't be linkified. --- icu4c/source/test/intltest/intltest.cpp | 2 +- icu4c/source/test/intltest/intltest.h | 21 ++++----- icu4c/source/tools/ctestfw/ctest.c | 4 +- icu4c/source/tools/ctestfw/unicode/ctest.h | 2 +- icu4c/source/tools/toolutil/udbgutil.cpp | 54 +++++++++++++--------- icu4c/source/tools/toolutil/udbgutil.h | 8 ---- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/icu4c/source/test/intltest/intltest.cpp b/icu4c/source/test/intltest/intltest.cpp index 15cd2d30776..cbfb5120372 100644 --- a/icu4c/source/test/intltest/intltest.cpp +++ b/icu4c/source/test/intltest/intltest.cpp @@ -1016,7 +1016,7 @@ UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) { UBool firstForTicket = TRUE, firstForWhere = TRUE; knownList = udbg_knownIssue_openU(knownList, ticket, fullpath, msg2.getTerminatedBuffer(), &firstForTicket, &firstForWhere); - msg2 = UNICODE_STRING_SIMPLE("(Known issue #") + + msg2 = UNICODE_STRING_SIMPLE("(Known issue ") + UnicodeString(ticket, -1, US_INV) + UNICODE_STRING_SIMPLE(") ") + msg; if(firstForTicket || firstForWhere) { infoln(msg2); diff --git a/icu4c/source/test/intltest/intltest.h b/icu4c/source/test/intltest/intltest.h index 027ebaa45e3..4ee9b83aba6 100644 --- a/icu4c/source/test/intltest/intltest.h +++ b/icu4c/source/test/intltest/intltest.h @@ -166,30 +166,27 @@ public: virtual void logln( void ); /** - * Replaces isICUVersionAtLeast and isICUVersionBefore - * log that an issue is known. + * Logs that an issue is known. Can be called multiple times. * Usually used this way: - * if( ... && logKnownIssue("12345", "some bug")) continue; - * @param ticket ticket string, "12345" or "cldrbug:1234" + * if( ... && logKnownIssue("ICU-12345", "some bug")) continue; + * @param ticket ticket string, "ICU-12345" or "CLDR-1234" * @param message optional message string * @return true if test should be skipped */ UBool logKnownIssue( const char *ticket, const UnicodeString &message ); /** - * Replaces isICUVersionAtLeast and isICUVersionBefore - * log that an issue is known. + * Logs that an issue is known. Can be called multiple times. * Usually used this way: - * if( ... && logKnownIssue("12345", "some bug")) continue; - * @param ticket ticket string, "12345" or "cldrbug:1234" + * if( ... && logKnownIssue("ICU-12345", "some bug")) continue; + * @param ticket ticket string, "ICU-12345" or "CLDR-1234" * @return true if test should be skipped */ UBool logKnownIssue( const char *ticket ); /** - * Replaces isICUVersionAtLeast and isICUVersionBefore - * log that an issue is known. + * Log that an issue is known. Can be called multiple times. * Usually used this way: - * if( ... && logKnownIssue("12345", "some bug")) continue; - * @param ticket ticket string, "12345" or "cldrbug:1234" + * if( ... && logKnownIssue("ICU-12345", "some bug")) continue; + * @param ticket ticket string, "ICU-12345" or "CLDR-1234" * @param message optional message string * @return true if test should be skipped */ diff --git a/icu4c/source/tools/ctestfw/ctest.c b/icu4c/source/tools/ctestfw/ctest.c index f0f665428e4..dc9a4b0f569 100644 --- a/icu4c/source/tools/ctestfw/ctest.c +++ b/icu4c/source/tools/ctestfw/ctest.c @@ -709,9 +709,9 @@ static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap &firstForTicket, &firstForWhere); if(firstForTicket || firstForWhere) { - log_info("(Known issue #%s) %s\n", ticket, buf); + log_info("(Known issue %s) %s\n", ticket, buf); } else { - log_verbose("(Known issue #%s) %s\n", ticket, buf); + log_verbose("(Known issue %s) %s\n", ticket, buf); } return TRUE; diff --git a/icu4c/source/tools/ctestfw/unicode/ctest.h b/icu4c/source/tools/ctestfw/unicode/ctest.h index c950bade694..6a29621127f 100644 --- a/icu4c/source/tools/ctestfw/unicode/ctest.h +++ b/icu4c/source/tools/ctestfw/unicode/ctest.h @@ -228,7 +228,7 @@ log_data_err(const char *pattern, ...); /** * Log a known issue. - * @param ticket ticket number such as "12345" for ICU tickets or "cldrbug:6636" for CLDR tickets. + * @param ticket ticket number such as "ICU-12345" for ICU tickets or "CLDR-6636" for CLDR tickets. * @param fmt ... sprintf-style format, optional message. can be NULL. * @return TRUE if known issue test should be skipped, FALSE if it should be run */ diff --git a/icu4c/source/tools/toolutil/udbgutil.cpp b/icu4c/source/tools/toolutil/udbgutil.cpp index 285f68a0ec6..993694546f4 100644 --- a/icu4c/source/tools/toolutil/udbgutil.cpp +++ b/icu4c/source/tools/toolutil/udbgutil.cpp @@ -594,24 +594,11 @@ U_CAPI void udbg_writeIcuInfo(FILE *out) { fprintf(out, " \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:" +#define UNICODE_BUG_URL "https://unicode-org.atlassian.net/browse/" +#define OLD_CLDR_PREFIX "cldrbug:" +#define CLDR_BUG_PREFIX "CLDR-" +#define ICU_BUG_PREFIX "ICU-" -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; -} #include @@ -641,8 +628,27 @@ KnownIssues::~KnownIssues() { } -void KnownIssues::add(const char *ticket, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere) +/** + * Map cldr:1234 to CLDR-1234 + * Map 1234 to ICU-1234 + */ +static std::string mapTicketId(const char *ticketStr) { + std::string ticket(ticketStr); + // TODO: Can remove this function once all logKnownIssue calls are switched over + // to the ICU-1234 and CLDR-1234 format. + if(ticket.rfind(OLD_CLDR_PREFIX) == 0) { + // map cldrbug:1234 to CLDR-1234 + ticket.replace(0, uprv_strlen(OLD_CLDR_PREFIX), CLDR_BUG_PREFIX); + } else if(::isdigit(ticket[0])) { + // map 1234 to ICU-1234 + ticket.insert(0, ICU_BUG_PREFIX); + } + return ticket; +} + +void KnownIssues::add(const char *ticketStr, const char *where, const UChar *msg, UBool *firstForTicket, UBool *firstForWhere) { + const std::string ticket = mapTicketId(ticketStr); if(fTable.find(ticket) == fTable.end()) { if(firstForTicket!=NULL) *firstForTicket = TRUE; fTable[ticket] = std::map < std::string, std::set < std::string > >(); @@ -664,8 +670,9 @@ void KnownIssues::add(const char *ticket, const char *where, const UChar *msg, U fTable[ticket][where].insert(std::string(icu::CStr(ustr)())); } -void KnownIssues::add(const char *ticket, const char *where, const char *msg, UBool *firstForTicket, UBool *firstForWhere) +void KnownIssues::add(const char *ticketStr, const char *where, const char *msg, UBool *firstForTicket, UBool *firstForWhere) { + const std::string ticket = mapTicketId(ticketStr); if(fTable.find(ticket) == fTable.end()) { if(firstForTicket!=NULL) *firstForTicket = TRUE; fTable[ticket] = std::map < std::string, std::set < std::string > >(); @@ -697,8 +704,13 @@ UBool KnownIssues::print() std::map < std::string, std::set < std::string > > >::iterator i = fTable.begin(); i != fTable.end(); i++ ) { - char URL[1024]; - std::cout << '#' << (*i).first << " <" << udbg_knownIssueURLFrom( (*i).first.c_str(), URL ) << ">" << std::endl; + const std::string ticketid = (*i).first; + std::cout << "[" << ticketid << "] "; + if(ticketid.rfind(ICU_BUG_PREFIX) == 0 || ticketid.rfind(CLDR_BUG_PREFIX) == 0) { + // If it's a unicode.org bug. + std::cout << UNICODE_BUG_URL << ticketid; + } // Else: some other kind of bug. Allow this, but without a URL. + std::cout << std::endl; for( std::map< std::string, std::set < std::string > >::iterator ii = (*i).second.begin(); ii != (*i).second.end(); diff --git a/icu4c/source/tools/toolutil/udbgutil.h b/icu4c/source/tools/toolutil/udbgutil.h index 2f186e6ed87..b9af132da5b 100644 --- a/icu4c/source/tools/toolutil/udbgutil.h +++ b/icu4c/source/tools/toolutil/udbgutil.h @@ -113,14 +113,6 @@ U_CAPI void udbg_writeIcuInfo(FILE *f); */ #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); - /** * Open (or reopen) a 'known issue' table. * @param ptr pointer to 'table'. Opaque.