aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-04-02 18:56:18 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-08-13 10:49:22 +0200
commit1a3738dfa85d6aa6771893c2a2b3cf874b492524 (patch)
tree299a0698bdc1e4eda07d8f3c9a73fddff67da1ff /src/qmltest
parent89bc860ff4c51c6e02f67198fa7dcf5e1241de80 (diff)
Read tests from qmltest file
Change-Id: I3550d20aac165539b97247d71e488fb3da30e48c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/quicktest.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 70b1cf401d..da4644f8aa 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -482,11 +482,35 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
const QFileInfo testPathInfo(testPath);
if (testPathInfo.isFile()) {
- if (!testPath.endsWith(QLatin1String(".qml"))) {
- qWarning("'%s' does not have the suffix '.qml'.", qPrintable(testPath));
+ if (testPath.endsWith(QLatin1String(".qml"))) {
+ files << testPath;
+ } else if (testPath.endsWith(QLatin1String(".qmltests"))) {
+ QFile file(testPath);
+ if (file.open(QIODevice::ReadOnly)) {
+ while (!file.atEnd()) {
+ const QString filePath = testPathInfo.dir()
+ .filePath(QString::fromUtf8(file.readLine()))
+ .trimmed();
+ const QFileInfo f(filePath);
+ if (f.exists())
+ files.append(filePath);
+ else
+ qWarning("The test file '%s' does not exists", qPrintable(filePath));
+ }
+ file.close();
+ files.sort();
+ if (files.isEmpty()) {
+ qWarning("The file '%s' does not contain any tests files",
+ qPrintable(testPath));
+ return 1;
+ }
+ } else {
+ qWarning("Could not read '%s'", qPrintable(testPath));
+ }
+ } else {
+ qWarning("'%s' does not have the suffix '.qml' or '.qmltests'.", qPrintable(testPath));
return 1;
}
- files << testPath;
} else if (testPathInfo.isDir()) {
// Scan the test data directory recursively, looking for "tst_*.qml" files.
const QStringList filters(QStringLiteral("tst_*.qml"));