summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-09-28 15:36:41 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-12-09 20:54:25 +0100
commitb67c367e0eb81a9062009abb6d5893e91719ca3e (patch)
tree0f7d736e74cd9357547e992a2df04fb0ab43cdd1 /src/testlib/qtestcase.cpp
parent93830d9ed3fcfe93331cc28f061db343e2224440 (diff)
Tidy up testlib's parsing of -callgrind parameter
Invert a condition to turn a nested if (that was missing one of its layers of braces) into an else-if chain, split some long strings to limit line length. Change-Id: I10d90487a09affe981aa11c3588281aeb3666df5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 8d0d549f17..9a93c41b5c 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -734,15 +734,18 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool
QTest::noCrashHandler = true;
#if QT_CONFIG(valgrind)
} else if (strcmp(argv[i], "-callgrind") == 0) {
- if (QBenchmarkValgrindUtils::haveValgrind())
- if (QFileInfo(QDir::currentPath()).isWritable()) {
- QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
- } else {
- fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
- }
- else {
- fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
- "Using the walltime measurer.\n");
+ if (!QBenchmarkValgrindUtils::haveValgrind()) {
+ fprintf(stderr,
+ "WARNING: Valgrind not found or too old. "
+ "Make sure it is installed and in your path. "
+ "Using the walltime measurer.\n");
+ } else if (QFileInfo(QDir::currentPath()).isWritable()) {
+ QBenchmarkGlobalData::current->setMode(
+ QBenchmarkGlobalData::CallgrindParentProcess);
+ } else {
+ fprintf(stderr,
+ "WARNING: Current directory not writable. "
+ "Using the walltime measurer.\n");
}
} else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindChildProcess);