ICU-3266 add -tz [zone] option to cintltst, and make default time zone be America/Los_Angeles (unless otherwise specified on command line)
X-SVN-Rev: 13162
This commit is contained in:
parent
35988562ec
commit
f5405f9191
@ -29,6 +29,7 @@
|
||||
#include "unicode/ucnv.h"
|
||||
#include "unicode/ures.h"
|
||||
#include "unicode/uclean.h"
|
||||
#include "unicode/ucal.h"
|
||||
#include "uoptions.h"
|
||||
|
||||
#ifdef XP_MAC_CONSOLE
|
||||
@ -112,9 +113,11 @@ int main(int argc, const char* const argv[])
|
||||
{
|
||||
int nerrors = 0;
|
||||
int warnOnMissingData = 0;
|
||||
int i;
|
||||
int i, j;
|
||||
TestNode *root;
|
||||
const char *warnOrErr = "Failure";
|
||||
const char *zone = "America/Los_Angeles";
|
||||
const char** argv2;
|
||||
|
||||
/* initial check for the default converter */
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
@ -123,13 +126,22 @@ int main(int argc, const char* const argv[])
|
||||
|
||||
U_MAIN_INIT_ARGS(argc, argv);
|
||||
|
||||
argv2 = (const char**) ctst_malloc(sizeof(char*) * argc);
|
||||
if (argv2 == NULL) {
|
||||
printf("*** Error: Out of memory (too many cmd line args?)\n");
|
||||
return 1;
|
||||
}
|
||||
argv2[0] = argv[0];
|
||||
|
||||
|
||||
/* Checkargs */
|
||||
/* TODO: Test framework arg handling needs to be decoupled from test execution
|
||||
* so that the args being processed here don't need special handling,
|
||||
* separate from the other test args.
|
||||
*/
|
||||
ICU_TRACE = UTRACE_OFF;
|
||||
for(i=1;i<argc;i++) {
|
||||
for(i=1,j=1;i<argc;i++) {
|
||||
argv2[j++] = argv[i];
|
||||
if(!strcmp(argv[i],"-w")) {
|
||||
warnOnMissingData = 1;
|
||||
warnOrErr = "Warning";
|
||||
@ -146,7 +158,30 @@ int main(int argc, const char* const argv[])
|
||||
else if (strcmp( argv[i], "-t_verbose") == 0) {
|
||||
ICU_TRACE = UTRACE_VERBOSE;
|
||||
}
|
||||
else if (strcmp( argv[i], "-tz") == 0) {
|
||||
zone = 0;
|
||||
if ((i+1) < argc) {
|
||||
switch (argv[i+1][0]) {
|
||||
case 0:
|
||||
++i; /* consume empty string in {-tz ""} */
|
||||
break;
|
||||
case '-':
|
||||
case '/':
|
||||
break; /* don't process next arg if it is -x or /x */
|
||||
default:
|
||||
zone = argv[++i]; /* next arg is zone */
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Consume args so processArgs doesn't see them (below).
|
||||
* This is ugly but it will get fixed when we do the reorg
|
||||
* of arg processing...later. We can't do all this in
|
||||
* processArgs because that library (ctestfw) doesn't link
|
||||
* common nor i18n, by design. */
|
||||
--j;
|
||||
}
|
||||
}
|
||||
argc = j;
|
||||
|
||||
|
||||
utrace_setFunctions(NULL, TraceEntry, TraceExit, TraceData, ICU_TRACE, &errorCode);
|
||||
@ -231,13 +266,30 @@ int main(int argc, const char* const argv[])
|
||||
|
||||
fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());
|
||||
|
||||
/* Set the default time zone */
|
||||
if (zone != 0) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
UChar zoneID[256];
|
||||
u_uastrncpy(zoneID, zone, 255);
|
||||
zoneID[255] = 0;
|
||||
ucal_setDefaultTimeZone(zoneID, &ec);
|
||||
if (U_FAILURE(ec)) {
|
||||
printf("*** Error: Failed to set default time zone to \"%s\": %s\n",
|
||||
zone, u_errorName(ec));
|
||||
u_cleanup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fprintf(stdout, "Default time zone for this run is %s\n",
|
||||
(zone!=0) ? zone : "UNSET");
|
||||
|
||||
/* Build a tree of all tests.
|
||||
* Subsequently will be used to find / iterate the tests to run */
|
||||
root = NULL;
|
||||
addAllTests(&root);
|
||||
|
||||
/* Tests acutally run HERE. TODO: separate command line option parsing & setting from test execution!! */
|
||||
nerrors = processArgs(root, argc, argv);
|
||||
nerrors = processArgs(root, argc, argv2);
|
||||
|
||||
if (--REPEAT_TESTS > 0) {
|
||||
printf("Repeating tests %d more time(s)\n", REPEAT_TESTS);
|
||||
|
Loading…
Reference in New Issue
Block a user