diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-28 11:44:01 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-04 23:10:19 +0000 |
commit | 5b9d5685ae7599e31fa8d61479c984508ec29abe (patch) | |
tree | aebc210e982414b4525cf5b16798c56347d96603 /src/testlib/qtestresult_p.h | |
parent | 4a1618ab9dfd27663e9882823e4f51e6b4d70775 (diff) |
testlib: Pass on file location on failure, but don't assume we have one
We try our best to pass on the file location of a failure, including for
fatal errors, but the reporting or logging machinery should not assume
there is one.
By passing on nullptr for the file location we allow the logging backends
to decide how to handle the situation, e.g. by not emitting extra fields
for failure location.
This effectively reverts c25687fa0b6e4be043e1f8c92c093d8b06ca06c4,
in favor of relying on the backends to cope with null filename,
which they already did.
As qFatal uses QMessageLogger, which by default disables file/line
information in release builds, we need to explicitly enable this in
our self-tests, to get uniform test results. Similarly, we disable
file/line info from testlib itself, as reporting Qt internal file
and line information for user diagnostics is less useful. The odd
one out there is qtestdata.cpp, which still ends up in test output
due to using QTEST_ASSERT instead of qFatal for its diagnostics.
Cleaning up that, and unifying how we report testlib issues to the
user, is left for another day.
Change-Id: Ib9451b8eed86fe3ade4a4dcaf0037e1a3450321c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fa8cffa4c97d2e46de9af6f5e91af9212e372204)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/testlib/qtestresult_p.h')
-rw-r--r-- | src/testlib/qtestresult_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h index 4da66885df..49d75adee9 100644 --- a/src/testlib/qtestresult_p.h +++ b/src/testlib/qtestresult_p.h @@ -77,7 +77,7 @@ public: static void reset(); static void setBlacklistCurrentTest(bool b); - static void addFailure(const char *message, const char *file, int line); + static void addFailure(const char *message, const char *file = nullptr, int line = 0); static bool compare(bool success, const char *failureMsg, char *val1, char *val2, const char *actual, const char *expected, |