diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c6bcf83..d7d6338 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,5 +1,8 @@ + + + @@ -12,36 +15,18 @@ - - - - - - - - - - - - - + + - - - - - - - - - - - - - + + + + + + - + - - + + + + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -97,53 +122,21 @@ - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -166,23 +159,23 @@ @@ -528,12 +521,14 @@ - + + + - @@ -548,18 +543,18 @@ - + - + - - + + - + @@ -598,11 +593,163 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -633,7 +780,6 @@ - @@ -682,7 +828,6 @@ - @@ -803,32 +948,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -857,64 +976,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -931,6 +992,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -941,5 +1032,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/examplar.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/examplar.cpp.o index bb10f29..1e08cc8 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/examplar.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/examplar.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Plan.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Plan.cpp.o index b4e6862..5f91c61 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Plan.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Plan.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Units.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Units.cpp.o index dbb5fb2..fa0b0aa 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Units.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders/Units.cpp.o differ diff --git a/cmake-build-debug/conf/test.plan b/cmake-build-debug/conf/test.plan index 16f219f..09eaa9a 100644 --- a/cmake-build-debug/conf/test.plan +++ b/cmake-build-debug/conf/test.plan @@ -1,8 +1,6 @@ { "plan": [ - { "name": "gcc is present", "depends on": [ null ] }, - { "name": "gcc can compile", "depends on": [ "gcc is present" ] }, - { "name": "gcc can compile2", "depends on": [ "gcc is present" ] }, - { "name": "gcc can compile", "depends on": [ "gcc is present" ] } + { "name": "independent test", "depends on": null }, + { "name": "dependent test", "depends on": [ "independent test", null, null ] } ] } \ No newline at end of file diff --git a/cmake-build-debug/conf/units/all_test.units b/cmake-build-debug/conf/units/all_test.units index 74937f1..f7166f2 100644 --- a/cmake-build-debug/conf/units/all_test.units +++ b/cmake-build-debug/conf/units/all_test.units @@ -1,19 +1,19 @@ { "units": [ { - "name": "gcc is present", - "target": "./ubuntu/xenial/check_gcc_present.run", - "output": "present", - "rectifier": "./ubuntu/xenial/install_gcc", + "name": "independent test", + "target": "/home/phanes/tests/test-script-pass.sh", + "output": "pass", + "rectifier": "/home/phanes/tests/test-script-rectifier.sh", "active": true, "required": true, "rectify": true }, { - "name": "gcc can compile", - "target": "./ubuntu/xenial/check_gcc_compiles.run", - "output": "can compile", - "rectifier": "echo pass", + "name": "dependent test", + "target": "/home/phanes/tests/test-script-pass.sh", + "output": "pass", + "rectifier": "/home/phanes/tests/test-script-rectifier.sh", "active": true, "required": true, "rectify": false diff --git a/cmake-build-debug/ftests b/cmake-build-debug/ftests index 485ceed..7dc289a 100755 Binary files a/cmake-build-debug/ftests and b/cmake-build-debug/ftests differ diff --git a/examplar.cpp b/examplar.cpp index 9533bb2..62ff37e 100644 --- a/examplar.cpp +++ b/examplar.cpp @@ -4,22 +4,38 @@ int main() { + // A Plan is made up of Tasks, and a Suite is made up of Units. + // A Plan declares what units are executed and a Suite declares the definitions of those units. Conf configuration = Conf("config.json"); - UnitHolder unitHolder = UnitHolder( configuration.get_units_path() ); - Plan plan = Plan( configuration.get_plan_path() ); + // load the configuration file which contains filepaths to definitions of a plan and definitions of units. + std::string definitions_file = configuration.get_units_path(); + std::string plan_file = configuration.get_plan_path(); - for ( int i = 0; i < plan.tasks.size(); ++i ) + Suite unit_definitions = Suite( definitions_file ); + + Plan plan = Plan( plan_file ); + + for ( int i = 0; i < plan.num_tasks(); ++i ) { - std::string current_task_name = plan.tasks[i].get_name(); - std::cout << "Found task name in \"" << configuration.get_plan_path() << "\":\t" << current_task_name << std::endl << std::endl; + Task current_task = plan.select_task_index( i ); - Unit current_unit = unitHolder.select_unit( current_task_name ); + Unit current_unit = unit_definitions.select_unit( current_task.get_name() ); - std::cout << "Associated Unit name:\t\t" << current_unit.get_name() << std::endl; - std::cout << "Associated Unit target:\t\t" << current_unit.get_target() << std::endl; - std::cout << "Associated Unit healer:\t\t" << current_unit.get_rectifier() << std::endl; - std::cout << "Associated Unit heals:\t\t" << current_unit.get_rectify() << std::endl << std::endl; + std::cout << "Found task name in \"" << configuration.get_plan_path() << "\":\t" << current_task.get_name() << std::endl << std::endl; + + std::cout << "Associated Unit name:\t\t" << current_unit.get_name() << std::endl; + std::cout << "Associated Unit target:\t\t" << current_unit.get_target() << std::endl; + std::cout << "Associated Unit healer:\t\t" << current_unit.get_rectifier() << std::endl; + std::cout << "Associated Unit heals:\t\t" << current_unit.get_rectify() << std::endl; + + Json::Value deps = current_task.get_dependencies(); + + for ( int j = 0; j < deps.size(); ++j ) + { + std::cout << "Associated Dependency:\t\t" << deps[j] << std::endl; + } + std::cout << std::endl; } return 0; diff --git a/src/loaders/Plan.cpp b/src/loaders/Plan.cpp index c3f373e..4eb8bc3 100644 --- a/src/loaders/Plan.cpp +++ b/src/loaders/Plan.cpp @@ -1,16 +1,71 @@ // // Created by phanes on 4/22/17. // - #include "Plan.h" + Task::Task( Json::Value loader_root ) { this->name = loader_root.get("name", "?").asString(); this->dependencies = loader_root.get("depends on", ""); + this->has_succeeded = false; } -std::string Task::get_name() { return this->name; } + +std::string Task::get_name() { return this->name; } +bool Task::isDone() { return this->has_succeeded; } +void Task::finish() { this->has_succeeded = true; } + +// returns Json::Value for dependencies Json::Value Task::get_dependencies() { return this->dependencies;} + + +Json::Value Task::set_dependencies() +{ + +} + + +int Plan::num_tasks() +{ + return (int)this->tasks.size(); +} + + +Task Plan::select_task_index(int index) { + return this->tasks[index]; +} + +Task Plan::select_task( std::string provided_name ) +{ +/* + * returns a task from a Plan object by name + * this will need reworked. maybe should return int, populate a pointer. + * error handling is the concern here. + */ + { + Task * returnable; + bool foundMatch = false; + + for ( int i = 0; i < this->tasks.size(); i++ ) + { + std::string task_name = this->tasks[i].get_name(); + if ( task_name == provided_name ) + { + returnable = & this->tasks[i]; + foundMatch = true; + break; + } + } + if (! foundMatch ) + { + std::cerr << "Task name \"" << provided_name << "\" was referenced but not defined!" << std::endl; + std::exit(1); + } + + return * returnable; + } +} + Plan::Plan( std::string filename ): JLoader( filename ) { /* Plan loads a file and deserializes the Unit JSON object to Task types as a vector member @@ -22,4 +77,4 @@ Plan::Plan( std::string filename ): JLoader( filename ) { this->tasks.push_back( Task( raw_tasks[index] ) ); } -}; \ No newline at end of file +}; diff --git a/src/loaders/Plan.h b/src/loaders/Plan.h index 7378c30..9d2af69 100644 --- a/src/loaders/Plan.h +++ b/src/loaders/Plan.h @@ -10,24 +10,30 @@ class Task { -private: - std::string name; - Json::Value dependencies; + private: + std::string name; + Json::Value dependencies; + bool has_succeeded; -public: - Task( Json::Value loader_root ); - std::string get_name(); - Json::Value get_dependencies(); + public: + Task( Json::Value loader_root ); + std::string get_name(); + Json::Value get_dependencies(); + Json::Value set_dependencies(); + bool isDone(); + void finish(); }; class Plan: public JLoader { -public: - using JLoader::JLoader; - std::vector tasks; - Plan( std::string filename ); + private: + std::vector tasks; + + public: + Plan( std::string filename ); + Task select_task( std::string provided_name ); + Task select_task_index( int index ); + int num_tasks(); }; - - #endif //FTESTS_PLAN_H diff --git a/src/loaders/Units.cpp b/src/loaders/Units.cpp index 594f5d4..1274ff1 100644 --- a/src/loaders/Units.cpp +++ b/src/loaders/Units.cpp @@ -3,7 +3,11 @@ // #include "Units.h" + Unit::Unit( Json::Value loader_root ) +/* + * Constructor for Unit type. Receives a UnitHolder loader_root. + */ { this->name = loader_root.get("name", "?").asString(); this->target = loader_root.get("target", "?").asString(); @@ -14,7 +18,9 @@ Unit::Unit( Json::Value loader_root ) this->rectify = loader_root.get("rectify", "?").asString(); } - +/* + * getters for Unit type. + */ std::string Unit::get_name() { return this->name; } std::string Unit::get_target() { return this->target; } std::string Unit::get_output() { return this->output; } @@ -23,20 +29,25 @@ std::string Unit::get_active() { return this->active; } std::string Unit::get_required() { return this->required; } std::string Unit::get_rectify() { return this->rectify; } -UnitHolder::UnitHolder( std::string filename ): JLoader( filename ) -{ -/* UnitHolder loads a file and deserializes the Unit JSON object to Unit types as a vector member - * UnitHolder { vector } +Suite::Suite( std::string filename ): JLoader( filename ) +/* Suite loads a file and deserializes the Unit JSON object to Unit types as a vector member + * Suite { vector } */ +{ Json::Value raw_units = this->get_root()["units"]; for ( int index = 0; index < raw_units.size(); index++ ) { - this->units.push_back(Unit( raw_units[index] )); + this->units.push_back( Unit( raw_units[ index ] ) ); } }; -Unit UnitHolder::select_unit(std::string provided_name) +Unit Suite::select_unit( std::string provided_name ) +/* + * returns a unit from a unitholder object by name + * this will need reworked. maybe should return int, populate a pointer. + * error handling is the concern here. + */ { Unit * returnable; bool foundMatch = false; @@ -53,7 +64,7 @@ Unit UnitHolder::select_unit(std::string provided_name) } if (! foundMatch ) { - std::cerr << "Unit name \"" << provided_name << "\" was referenced in a plan task but not defined!" << std::endl; + std::cerr << "Unit name \"" << provided_name << "\" was referenced but not defined!" << std::endl; std::exit(1); } diff --git a/src/loaders/Units.h b/src/loaders/Units.h index 41cfaf8..58b1cb5 100644 --- a/src/loaders/Units.h +++ b/src/loaders/Units.h @@ -11,33 +11,37 @@ class Unit { -private: - std::string name; - std::string target; - std::string output; - std::string rectifier; - std::string active; - std::string required; - std::string rectify; + private: + std::string name; + std::string target; + std::string output; + std::string rectifier; + std::string active; + std::string required; + std::string rectify; -public: - Unit( Json::Value loader_root ); - std::string get_name(); - std::string get_target(); - std::string get_output(); - std::string get_rectifier(); - std::string get_active(); - std::string get_required(); - std::string get_rectify(); + public: + Unit( Json::Value loader_root ); + std::string get_name(); + std::string get_target(); + std::string get_output(); + std::string get_rectifier(); + std::string get_active(); + std::string get_required(); + std::string get_rectify(); }; -class UnitHolder: public JLoader +class Suite: public JLoader { -public: - using JLoader::JLoader; - std::vector units; - UnitHolder( std::string filename ); - Unit select_unit( std::string provided_name ); + private: + std::vector units; + + public: + // constructor + Suite( std::string filename ); + + // returns the unit type identified by name or null + Unit select_unit( std::string provided_name ); };