diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-12-09 22:56:15 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-12-11 01:01:13 +0100 |
commit | 1b29e4a6e8fb9a27a96bdfadb69b12cc2436db6e (patch) | |
tree | 82550f5a56eb8be86256efeef0b356a719644ae0 /tests/hawd | |
parent | 326d6181e6a71e5ff4c82784ada7af3f55ec6e05 (diff) | |
download | sink-1b29e4a6e8fb9a27a96bdfadb69b12cc2436db6e.tar.gz sink-1b29e4a6e8fb9a27a96bdfadb69b12cc2436db6e.zip |
add a checkall
Diffstat (limited to 'tests/hawd')
-rw-r--r-- | tests/hawd/module.cpp | 6 | ||||
-rw-r--r-- | tests/hawd/module.h | 2 | ||||
-rw-r--r-- | tests/hawd/modules/check.cpp | 30 | ||||
-rw-r--r-- | tests/hawd/modules/check.h | 11 |
4 files changed, 36 insertions, 13 deletions
diff --git a/tests/hawd/module.cpp b/tests/hawd/module.cpp index d4c3059..eb45def 100644 --- a/tests/hawd/module.cpp +++ b/tests/hawd/module.cpp | |||
@@ -50,6 +50,10 @@ void Module::loadModules() | |||
50 | { | 50 | { |
51 | addModule(List()); | 51 | addModule(List()); |
52 | addModule(Check()); | 52 | addModule(Check()); |
53 | addModule(CheckAll()); | ||
54 | // addModule(Print()); | ||
55 | // addModule(Annotate()); | ||
56 | // addModule(Remove()); | ||
53 | } | 57 | } |
54 | 58 | ||
55 | void Module::printCommands() | 59 | void Module::printCommands() |
@@ -134,7 +138,7 @@ bool Module::matches(const QStringList &commands, State &state) const | |||
134 | return false; | 138 | return false; |
135 | } | 139 | } |
136 | 140 | ||
137 | QListIterator<Syntax> syntaxIt(m_syntax.children); | 141 | QVectorIterator<Syntax> syntaxIt(m_syntax.children); |
138 | const Syntax *syntax = &m_syntax; | 142 | const Syntax *syntax = &m_syntax; |
139 | QStringList tailCommands; | 143 | QStringList tailCommands; |
140 | while (commandIt.hasNext() && syntaxIt.hasNext()) { | 144 | while (commandIt.hasNext() && syntaxIt.hasNext()) { |
diff --git a/tests/hawd/module.h b/tests/hawd/module.h index 8f94707..856c09c 100644 --- a/tests/hawd/module.h +++ b/tests/hawd/module.h | |||
@@ -36,7 +36,7 @@ public: | |||
36 | Syntax(const QString &keyword, std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), bool eventDriven = false); | 36 | Syntax(const QString &keyword, std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), bool eventDriven = false); |
37 | QString keyword; | 37 | QString keyword; |
38 | std::function<bool(const QStringList &, State &)> lambda; | 38 | std::function<bool(const QStringList &, State &)> lambda; |
39 | QList<Syntax> children; | 39 | QVector<Syntax> children; |
40 | bool eventDriven; | 40 | bool eventDriven; |
41 | }; | 41 | }; |
42 | 42 | ||
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 @@ | |||
29 | namespace HAWD | 29 | namespace HAWD |
30 | { | 30 | { |
31 | 31 | ||
32 | CheckAll::CheckAll() | ||
33 | : Module() | ||
34 | { | ||
35 | setSyntax(Syntax("checkall", &CheckAll::check)); | ||
36 | } | ||
37 | |||
38 | bool 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 | |||
32 | Check::Check() | 49 | Check::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 | ||
40 | bool Check::check(const QStringList &commands, State &state) | 58 | bool 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 | { |
29 | public: | 29 | public: |
30 | Check(); | 30 | Check(); |
31 | static void checkFile(const QString &name, State &state); | ||
32 | |||
33 | private: | ||
34 | static bool check(const QStringList &commands, State &state); | ||
35 | }; | ||
36 | |||
37 | class CheckAll : public Module | ||
38 | { | ||
39 | public: | ||
40 | CheckAll(); | ||
31 | 41 | ||
32 | private: | 42 | private: |
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 |