summaryrefslogtreecommitdiffstats
path: root/tests/hawd/modules
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hawd/modules')
-rw-r--r--tests/hawd/modules/check.cpp30
-rw-r--r--tests/hawd/modules/check.h11
2 files changed, 30 insertions, 11 deletions
diff --git a/tests/hawd/modules/check.cpp b/tests/hawd/modules/check.cpp
index 1359b3d..e334fb8 100644
--- a/tests/hawd/modules/check.cpp
+++ b/tests/hawd/modules/check.cpp
@@ -29,12 +29,30 @@
29namespace HAWD 29namespace HAWD
30{ 30{
31 31
32CheckAll::CheckAll()
33 : Module()
34{
35 setSyntax(Syntax("checkall", &CheckAll::check));
36}
37
38bool CheckAll::check(const QStringList &commands, State &state)
39{
40 QDir project(state.projectPath());
41 project.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot | QDir::NoSymLinks);
42 for (const QString &entry: project.entryList()) {
43 Check::checkFile(entry, state);
44 }
45
46 return true;
47}
48
32Check::Check() 49Check::Check()
33 : Module() 50 : Module()
34{ 51{
35 Syntax top("check", &Check::check); 52 Syntax top("check", &Check::check);
36 setDescription(QObject::tr("Checks a dataset description for validity and prints out any errors it finds"));
37 setSyntax(top); 53 setSyntax(top);
54
55 setDescription(QObject::tr("Checks a dataset description for validity and prints out any errors it finds"));
38} 56}
39 57
40bool Check::check(const QStringList &commands, State &state) 58bool Check::check(const QStringList &commands, State &state)
@@ -43,15 +61,7 @@ bool Check::check(const QStringList &commands, State &state)
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; 61 std::cout << QObject::tr("Please provide the name of a dataset definition file. (Use the 'list' command to see available datasets.)").toStdString() << std::endl;
44 } else { 62 } else {
45 for (const QString &name: commands) { 63 for (const QString &name: commands) {
46 if (name == "*") { 64 checkFile(name, state);
47 QDir project(state.projectPath());
48 project.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot | QDir::NoSymLinks);
49 for (const QString &entry: project.entryList()) {
50 checkFile(entry, state);
51 }
52 } else {
53 checkFile(name, state);
54 }
55 } 65 }
56 } 66 }
57 67
diff --git a/tests/hawd/modules/check.h b/tests/hawd/modules/check.h
index 035f45a..44721f4 100644
--- a/tests/hawd/modules/check.h
+++ b/tests/hawd/modules/check.h
@@ -28,10 +28,19 @@ class Check : public Module
28{ 28{
29public: 29public:
30 Check(); 30 Check();
31 static void checkFile(const QString &name, State &state);
32
33private:
34 static bool check(const QStringList &commands, State &state);
35};
36
37class CheckAll : public Module
38{
39public:
40 CheckAll();
31 41
32private: 42private:
33 static bool check(const QStringList &commands, State &state); 43 static bool check(const QStringList &commands, State &state);
34 static void checkFile(const QString &name, State &state);
35}; 44};
36 45
37} // namespace HAWD 46} // namespace HAWD