Send error messages to stderr rather than stdout
The commit changes printf's that output error and warning messages to send their text to the stderr stream. Non-error output, such as that produced by passing the -help option to a test, still goes to stdout. Change-Id: Iea4d62451e3e7e84c654859cb09ea7e717511d13 Reviewed-on: http://codereview.qt.nokia.com/3636 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
043914bd97
commit
15400d9466
@ -76,7 +76,7 @@ void QAbstractTestLogger::startLogging(const char *filename)
|
|||||||
stream = ::fopen(filename, "wt");
|
stream = ::fopen(filename, "wt");
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
#endif
|
#endif
|
||||||
printf("Unable to open file for logging: %s", filename);
|
fprintf(stderr, "Unable to open file for logging: %s", filename);
|
||||||
::exit(1);
|
::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1018,12 +1018,12 @@ Q_TESTLIB_EXPORT bool printAvailableFunctions = false;
|
|||||||
Q_TESTLIB_EXPORT QStringList testFunctions;
|
Q_TESTLIB_EXPORT QStringList testFunctions;
|
||||||
Q_TESTLIB_EXPORT QStringList testTags;
|
Q_TESTLIB_EXPORT QStringList testTags;
|
||||||
|
|
||||||
static void qPrintTestSlots()
|
static void qPrintTestSlots(FILE *stream)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
|
for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
|
||||||
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
|
QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i);
|
||||||
if (isValidSlot(sl))
|
if (isValidSlot(sl))
|
||||||
printf("%s\n", sl.signature());
|
fprintf(stream, "%s\n", sl.signature());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,7 +1032,7 @@ static int qToInt(char *str)
|
|||||||
char *pEnd;
|
char *pEnd;
|
||||||
int l = (int)strtol(str, &pEnd, 10);
|
int l = (int)strtol(str, &pEnd, 10);
|
||||||
if (*pEnd != 0) {
|
if (*pEnd != 0) {
|
||||||
printf("Invalid numeric parameter: '%s'\n", str);
|
fprintf(stderr, "Invalid numeric parameter: '%s'\n", str);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@ -1100,7 +1100,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
if (qml) {
|
if (qml) {
|
||||||
QTest::printAvailableFunctions = true;
|
QTest::printAvailableFunctions = true;
|
||||||
} else {
|
} else {
|
||||||
qPrintTestSlots();
|
qPrintTestSlots(stdout);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
} else if(strcmp(argv[i], "-xunitxml") == 0){
|
} else if(strcmp(argv[i], "-xunitxml") == 0){
|
||||||
@ -1121,35 +1121,35 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
QSignalDumper::startDump();
|
QSignalDumper::startDump();
|
||||||
} else if (strcmp(argv[i], "-o") == 0) {
|
} else if (strcmp(argv[i], "-o") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-o needs an extra parameter specifying the filename\n");
|
fprintf(stderr, "-o needs an extra parameter specifying the filename\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTestLog::redirectOutput(argv[++i]);
|
QTestLog::redirectOutput(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-eventdelay") == 0) {
|
} else if (strcmp(argv[i], "-eventdelay") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-eventdelay needs an extra parameter to indicate the delay(ms)\n");
|
fprintf(stderr, "-eventdelay needs an extra parameter to indicate the delay(ms)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTest::eventDelay = qToInt(argv[++i]);
|
QTest::eventDelay = qToInt(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-keydelay") == 0) {
|
} else if (strcmp(argv[i], "-keydelay") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-keydelay needs an extra parameter to indicate the delay(ms)\n");
|
fprintf(stderr, "-keydelay needs an extra parameter to indicate the delay(ms)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTest::keyDelay = qToInt(argv[++i]);
|
QTest::keyDelay = qToInt(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-mousedelay") == 0) {
|
} else if (strcmp(argv[i], "-mousedelay") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-mousedelay needs an extra parameter to indicate the delay(ms)\n");
|
fprintf(stderr, "-mousedelay needs an extra parameter to indicate the delay(ms)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTest::mouseDelay = qToInt(argv[++i]);
|
QTest::mouseDelay = qToInt(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-maxwarnings") == 0) {
|
} else if (strcmp(argv[i], "-maxwarnings") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-maxwarnings needs an extra parameter with the amount of warnings\n");
|
fprintf(stderr, "-maxwarnings needs an extra parameter with the amount of warnings\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTestLog::setMaxWarnings(qToInt(argv[++i]));
|
QTestLog::setMaxWarnings(qToInt(argv[++i]));
|
||||||
@ -1166,10 +1166,10 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
if (QFileInfo(QDir::currentPath()).isWritable()) {
|
if (QFileInfo(QDir::currentPath()).isWritable()) {
|
||||||
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
|
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
|
||||||
} else {
|
} else {
|
||||||
printf("WARNING: Current directory not writable. Using the walltime measurer.\n");
|
fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
|
fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
|
||||||
"Using the walltime measurer.\n");
|
"Using the walltime measurer.\n");
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option
|
} else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option
|
||||||
@ -1194,28 +1194,28 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
QTest::seed = longSeed;
|
QTest::seed = longSeed;
|
||||||
}
|
}
|
||||||
if (!argumentOk) {
|
if (!argumentOk) {
|
||||||
printf("-seed needs an extra positive integer parameter to specify the seed\n");
|
fprintf(stderr, "-seed needs an extra positive integer parameter to specify the seed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QTest::seedSet = true;
|
QTest::seedSet = true;
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-minimumvalue") == 0) {
|
} else if (strcmp(argv[i], "-minimumvalue") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
|
fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]);
|
QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-iterations") == 0) {
|
} else if (strcmp(argv[i], "-iterations") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-iterations needs an extra parameter to indicate the number of iterations\n");
|
fprintf(stderr, "-iterations needs an extra parameter to indicate the number of iterations\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]);
|
QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-median") == 0) {
|
} else if (strcmp(argv[i], "-median") == 0) {
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-median needs an extra parameter to indicate the number of median iterations\n");
|
fprintf(stderr, "-median needs an extra parameter to indicate the number of median iterations\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
|
QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]);
|
||||||
@ -1230,23 +1230,23 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
} else if (strcmp(argv[i], "-graphicssystem") == 0) {
|
} else if (strcmp(argv[i], "-graphicssystem") == 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
if (i + 1 >= argc) {
|
if (i + 1 >= argc) {
|
||||||
printf("-graphicssystem needs an extra parameter specifying the graphics system\n");
|
fprintf(stderr, "-graphicssystem needs an extra parameter specifying the graphics system\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
} else if (argv[i][0] == '-') {
|
} else if (argv[i][0] == '-') {
|
||||||
printf("Unknown option: '%s'\n\n%s", argv[i], testOptions);
|
fprintf(stderr, "Unknown option: '%s'\n\n%s", argv[i], testOptions);
|
||||||
if (qml) {
|
if (qml) {
|
||||||
printf ("\nqmltest related options:\n"
|
fprintf(stderr, "\nqmltest related options:\n"
|
||||||
" -import : Specify an import directory.\n"
|
" -import : Specify an import directory.\n"
|
||||||
" -input : Specify the root directory for test cases.\n"
|
" -input : Specify the root directory for test cases.\n"
|
||||||
" -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
|
" -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n"
|
fprintf(stderr, "\n"
|
||||||
" -help : This help\n");
|
" -help : This help\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (qml) {
|
} else if (qml) {
|
||||||
// We can't check the availability of test functions until
|
// We can't check the availability of test functions until
|
||||||
@ -1295,9 +1295,9 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
QTest::qt_snprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
|
QTest::qt_snprintf(buf + off, qMin(512 - off, 3), "()"); // append "()"
|
||||||
int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
|
int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf);
|
||||||
if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) {
|
if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) {
|
||||||
printf("Unknown testfunction: '%s'\n", buf);
|
fprintf(stderr, "Unknown testfunction: '%s'\n", buf);
|
||||||
printf("Available testfunctions:\n");
|
fprintf(stderr, "Available testfunctions:\n");
|
||||||
qPrintTestSlots();
|
qPrintTestSlots(stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
testFuncs[testFuncCount].set(idx, data);
|
testFuncs[testFuncCount].set(idx, data);
|
||||||
@ -1307,7 +1307,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (QTest::seedSet && !QTest::randomOrder) {
|
if (QTest::seedSet && !QTest::randomOrder) {
|
||||||
printf("-seed requires -random\n");
|
fprintf(stderr, "-seed requires -random\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1466,8 +1466,8 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
|
|||||||
if (!*data)
|
if (!*data)
|
||||||
data = 0;
|
data = 0;
|
||||||
else {
|
else {
|
||||||
printf("Unknown testdata for function %s: '%s'\n", slotName, data);
|
fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
|
||||||
printf("Function has no testdata.\n");
|
fprintf(stderr, "Function has no testdata.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1492,10 +1492,10 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data && !foundFunction) {
|
if (data && !foundFunction) {
|
||||||
printf("Unknown testdata for function %s: '%s'\n", slotName, data);
|
fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
|
||||||
printf("Available testdata:\n");
|
fprintf(stderr, "Available testdata:\n");
|
||||||
for(int i = 0; i < table.dataCount(); ++i)
|
for(int i = 0; i < table.dataCount(); ++i)
|
||||||
printf("%s\n", table.testData(i)->dataTag());
|
fprintf(stderr, "%s\n", table.testData(i)->dataTag());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user