Showing the changes to tests/script-engine/src/ScriptEngineNetworkedTests.cpp (1 of 1 file). Show all
Unified · Split
| @@ -146,10 +146,12 @@ void ScriptEngineNetworkedTests::testScriptRequire() { · 145 unmodified lines | ||
| 146 | 146 | QVERIFY(!sm->isStopped()); |
| 147 | 147 | QVERIFY(sm->isFinished()); |
| 148 | 148 | |
| 149 | − QVERIFY(printed.length() == expected.length()); | |
| 150 | − for(int i=0;i<printed.length();i++) { | |
| 151 | − QString nomatch = QString("Result '%1' didn't match expected '%2'").arg(printed[i]).arg(expected[i]); | |
| 152 | − QVERIFY2(printed[i] == expected[i], qPrintable(nomatch)); | |
| 149 | + qDebug() << "Script printed :" << printed; | |
| 150 | + qDebug() << "Expected output:" << expected; | |
| 151 | + | |
| 152 | + for(const auto &str : expected) { | |
| 153 | + QString nomatch = QString("Result didn't contain expected string '%1'").arg(str); | |
| 154 | + QVERIFY2(printed.contains(str), qPrintable(nomatch)); | |
| 153 | 155 | } |
| 154 | 156 | } |
| 155 | 157 | |
| @@ -179,11 +181,11 @@ void ScriptEngineNetworkedTests::testRequire() { · 23 unmodified lines | ||
| 179 | 181 | QVERIFY(!sm->isStopped()); |
| 180 | 182 | QVERIFY(sm->isFinished()); |
| 181 | 183 | |
| 182 | − QVERIFY(printed.length() == expected.length()); | |
| 183 | − for(int i=0;i<printed.length();i++) { | |
| 184 | − QString nomatch = QString("Result '%1' didn't match expected '%2'").arg(printed[i]).arg(expected[i]); | |
| 185 | − QVERIFY2(printed[i] == expected[i], qPrintable(nomatch)); | |
| 184 | + for(const auto &str : expected) { | |
| 185 | + QString nomatch = QString("Result didn't contain expected string '%1'").arg(str); | |
| 186 | + QVERIFY2(printed.contains(str), qPrintable(nomatch)); | |
| 186 | 187 | } |
| 188 | + | |
| 187 | 189 | } |
| 188 | 190 | |
| 189 | 191 | |
| @@ -194,6 +196,7 @@ void ScriptEngineNetworkedTests::testRequireInfinite() { · 4 unmodified lines | ||
| 194 | 196 | "print(\"Done\");" |
| 195 | 197 | "Script.stop(true);", "testRequireInf.js"); |
| 196 | 198 | QString errors; |
| 199 | + QStringList printed; | |
| 197 | 200 | |
| 198 | 201 | |
| 199 | 202 | |
| @@ -204,6 +207,9 @@ void ScriptEngineNetworkedTests::testRequireInfinite() { · 4 unmodified lines | ||
| 204 | 207 | connect(sm.get(), &ScriptManager::errorMessage, [&errors](const QString& message, const QString& engineName){ |
| 205 | 208 | errors.append(message); |
| 206 | 209 | }); |
| 210 | + connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | |
| 211 | + printed.append(message); | |
| 212 | + }); | |
| 207 | 213 | |
| 208 | 214 | |
| 209 | 215 | qInfo() << "About to run script"; |
| @@ -213,5 +219,6 @@ void ScriptEngineNetworkedTests::testRequireInfinite() { · 3 unmodified lines | ||
| 213 | 219 | QVERIFY(!sm->isStopped()); |
| 214 | 220 | QVERIFY(sm->isFinished()); |
| 215 | 221 | |
| 216 | − QVERIFY(errors.contains("Maximum call stack size exceeded")); | |
| 222 | + // Acceptable results: either failing, or realizing a prior module is already included | |
| 223 | + QVERIFY(errors.contains("Maximum call stack size exceeded") || printed.contains("Done") ); | |
| 217 | 224 | } |