aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-11-10 21:09:08 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-11-11 09:35:51 +0100
commitf84282dad7b28048c42f142132983ab2d6413783 (patch)
treeaeb5e8159f7f3c8177c4dc194d3bd6ebfea79f94 /src/imports
parenta02ed4f55522174be368f2fe208eb4f57fd58107 (diff)
testlib: Don't misuse the Qt object for storing test results
I'm pretty sure ".pragma library" works as intended by now. That comment was from 2011. Task-number: QTBUG-88372 Change-Id: I1f5baed221f7eebe62bb4b12940725d565b67793 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/testlib/testlogger.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/imports/testlib/testlogger.js b/src/imports/testlib/testlogger.js
index af6522c698..52a79806b9 100644
--- a/src/imports/testlib/testlogger.js
+++ b/src/imports/testlib/testlogger.js
@@ -39,14 +39,12 @@
.pragma library
-// We need a global place to store the results that can be
-// shared between multiple TestCase instances. Because QML
-// creates a separate scope for every inclusion of this file,
-// we hijack the global "Qt" object to store our data.
+var testResults = null;
+
function log_init_results()
{
- if (!Qt.testResults) {
- Qt.testResults = {
+ if (!testResults) {
+ testResults = {
reportedStart: false,
nextId: 0,
testCases: []
@@ -57,40 +55,40 @@ function log_init_results()
function log_register_test(name)
{
log_init_results()
- var testId = Qt.testResults.nextId++
- Qt.testResults.testCases.push(testId)
+ var testId = testResults.nextId++
+ testResults.testCases.push(testId)
return testId
}
function log_optional_test(testId)
{
log_init_results()
- var index = Qt.testResults.testCases.indexOf(testId)
+ var index = testResults.testCases.indexOf(testId)
if (index >= 0)
- Qt.testResults.testCases.splice(index, 1)
+ testResults.testCases.splice(index, 1)
}
function log_mandatory_test(testId)
{
log_init_results()
- var index = Qt.testResults.testCases.indexOf(testId)
+ var index = testResults.testCases.indexOf(testId)
if (index == -1)
- Qt.testResults.testCases.push(testId)
+ testResults.testCases.push(testId)
}
function log_start_test()
{
log_init_results()
- if (Qt.testResults.reportedStart)
+ if (testResults.reportedStart)
return false
- Qt.testResults.reportedStart = true
+ testResults.reportedStart = true
return true
}
function log_complete_test(testId)
{
- var index = Qt.testResults.testCases.indexOf(testId)
+ var index = testResults.testCases.indexOf(testId)
if (index >= 0)
- Qt.testResults.testCases.splice(index, 1)
- return Qt.testResults.testCases.length > 0
+ testResults.testCases.splice(index, 1)
+ return testResults.testCases.length > 0
}