summaryrefslogtreecommitdiffstats
path: root/tests/hawd/modules/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hawd/modules/check.cpp')
-rw-r--r--tests/hawd/modules/check.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/hawd/modules/check.cpp b/tests/hawd/modules/check.cpp
index c83ed39..1359b3d 100644
--- a/tests/hawd/modules/check.cpp
+++ b/tests/hawd/modules/check.cpp
@@ -21,6 +21,7 @@
21 21
22#include "../datasetdefinition.h" 22#include "../datasetdefinition.h"
23 23
24#include <QDir>
24#include <QObject> 25#include <QObject>
25 26
26#include <iostream> 27#include <iostream>
@@ -32,6 +33,7 @@ Check::Check()
32 : Module() 33 : Module()
33{ 34{
34 Syntax top("check", &Check::check); 35 Syntax top("check", &Check::check);
36 setDescription(QObject::tr("Checks a dataset description for validity and prints out any errors it finds"));
35 setSyntax(top); 37 setSyntax(top);
36} 38}
37 39
@@ -41,11 +43,14 @@ bool Check::check(const QStringList &commands, State &state)
41 std::cout << QObject::tr("Please provide the name of a dataset definition file. (Use the 'list' command to see available datasets.)").toStdString() << std::endl; 43 std::cout << QObject::tr("Please provide the name of a dataset definition file. (Use the 'list' command to see available datasets.)").toStdString() << std::endl;
42 } else { 44 } else {
43 for (const QString &name: commands) { 45 for (const QString &name: commands) {
44 DatasetDefinition def = state.datasetDefinition(name); 46 if (name == "*") {
45 if (def.isValid()) { 47 QDir project(state.projectPath());
46 std::cout << QObject::tr("%1 is OK").arg(name).toStdString() << std::endl; 48 project.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot | QDir::NoSymLinks);
49 for (const QString &entry: project.entryList()) {
50 checkFile(entry, state);
51 }
47 } else { 52 } else {
48 std::cout << QObject::tr("%1 has errors: %2").arg(name).arg(def.lastError()).toStdString() << std::endl; 53 checkFile(name, state);
49 } 54 }
50 } 55 }
51 } 56 }
@@ -53,5 +58,15 @@ bool Check::check(const QStringList &commands, State &state)
53 return true; 58 return true;
54} 59}
55 60
61void Check::checkFile(const QString &name, State &state)
62{
63 DatasetDefinition def = state.datasetDefinition(name);
64 if (def.isValid()) {
65 std::cout << QObject::tr("%1 is OK").arg(name).toStdString() << std::endl;
66 } else {
67 std::cout << QObject::tr("%1 has errors: %2").arg(name).arg(def.lastError()).toStdString() << std::endl;
68 }
69}
70
56} // namespace HAWD 71} // namespace HAWD
57 72