pushing local

master
Chris Punches 2017-06-18 10:39:46 -04:00
parent 36f34469fb
commit c8b0872993
10 changed files with 51 additions and 35 deletions

View File

@ -1,4 +1,4 @@
{ {
"units_path": "/home/phanes/Development/internal/ftests/conf/units/all_test.units", "units_path": "/home/phanes/Development/internal/Examplar/conf/units/all_test.units",
"plan_path": "/home/phanes/Development/internal/ftests/conf/plans/test.plan" "plan_path": "/home/phanes/Development/internal/Examplar/conf/plans/test.plan"
} }

View File

@ -2,9 +2,9 @@
"units": [ "units": [
{ {
"name": "independent test", "name": "independent test",
"target": "/home/phanes/tests/test-script-pass.sh", "target": "/bin/pwd",
"output": "pass", "output": "pass",
"rectifier": "/home/phanes/tests/test-script-rectifier.sh", "rectifier": "/bin/pwd",
"active": true, "active": true,
"required": true, "required": true,
"rectify": true "rectify": true

View File

@ -6,16 +6,14 @@ int main( )
{ {
// A Plan is made up of Tasks, and a Suite is made up of Units. // 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. // A Plan declares what units are executed and a Suite declares the definitions of those units.
Conf configuration = Conf("/home/phanes/Development/internal/ftests/conf/config.json"); Conf configuration = Conf("/home/phanes/Development/internal/Examplar/conf/config.json");
// load the configuration file which contains filepaths to definitions of a plan and definitions of units. // 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 definitions_file = configuration.get_units_path();
std::string plan_file = configuration.get_plan_path(); std::string plan_file = configuration.get_plan_path();
// std::cout << definitions_file << std::endl << plan_file << std::endl;
Suite available_definitions;
std::cout << definitions_file << std::endl << plan_file << std::endl;
// Suite * unit_definitions = new Suite(); // Suite * unit_definitions = new Suite();

View File

@ -318,8 +318,7 @@ namespace Json {
lastValue_(), commentsBefore_(), features_(features), collectComments_() { lastValue_(), commentsBefore_(), features_(features), collectComments_() {
} }
bool bool Reader::parse(const std::string& document, Value& root, bool collectComments) {
Reader::parse(const std::string& document, Value& root, bool collectComments) {
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity()); JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
std::swap(documentCopy, document_); std::swap(documentCopy, document_);
const char* begin = document_.c_str(); const char* begin = document_.c_str();

View File

@ -19,10 +19,10 @@ Conf::Conf( std::string filename ): JSON_Loader()
this->load_json_file( filename, true ); this->load_json_file( filename, true );
// find the path to the plan file // find the path to the plan file
if ( this->get_key( this->plan_path, "plan_path", true) != 0 ) { throw CONF_PLANPATH_INVALID(); } if (this->get_serialized(this->plan_path, "plan_path", true) != 0 ) { throw CONF_PLANPATH_INVALID(); }
// find the path to the unit definitions file // find the path to the unit definitions file
if ( this->get_key( this->units_path, "units_path", true) != 0 ) { throw CONF_UNITSPATH_INVALID(); } if (this->get_serialized(this->units_path, "units_path", true) != 0 ) { throw CONF_UNITSPATH_INVALID(); }
}; };
std::string Conf::get_plan_path() std::string Conf::get_plan_path()

View File

@ -70,7 +70,7 @@ void JSON_Loader::load_json_string( std::string input, bool verbose )
Json::Reader json_reader; Json::Reader json_reader;
// the deserialized json type to contain what's read by the reader // the deserialized json type to contain what's read by the reader
Json::Value json_root; // Json::Value json_root;
// create the ifstream file handle // create the ifstream file handle
std::ifstream json_file_ifstream( input.c_str(), std::ifstream::binary ); std::ifstream json_file_ifstream( input.c_str(), std::ifstream::binary );
@ -112,11 +112,11 @@ std::string JSON_Loader::as_string()
return this->json_root.asString(); return this->json_root.asString();
} }
// returns the string representation of the value of a key // returns the serialized representation of the value of a key
// the Jason::Value object to assign the fetched value to // the Jason::Value object to assign the fetched value to
// verbosity flag // verbosity flag
// exit or not on failure // exit or not on failure
int JSON_Loader::get_key( Json::Value &input, std::string key, bool verbose) int JSON_Loader::get_serialized(Json::Value &input, std::string key, bool verbose)
{ {
// throw if the class is not ready to be used. // throw if the class is not ready to be used.
if ( ! this->populated ) { throw JSON_Loader_NotReady(); } if ( ! this->populated ) { throw JSON_Loader_NotReady(); }
@ -129,7 +129,6 @@ int JSON_Loader::get_key( Json::Value &input, std::string key, bool verbose)
} }
// key was not found // key was not found
// shouldn't the be handled further up?
if ( verbose ) if ( verbose )
{ {
// verbose mode tells the user what key we were looking for. // verbose mode tells the user what key we were looking for.

View File

@ -27,10 +27,11 @@ class JSON_Loader
void load_json_string( std::string input, bool verbose ); void load_json_string( std::string input, bool verbose );
// return as a JSONCPP serialized object // return as a JSONCPP serialized object
Json::Value as_serialized(); // deprecated -- these aren't really used.
std::string as_string(); // Json::Value as_serialized();
// std::string as_string();
// safely handle key retrieval (if we want it to be safe) // safely handle deserialized type retrieval (if we want it to be safe)
int get_key( Json::Value &input, std::string key, bool verbose); int get_serialized(Json::Value &input, std::string key, bool verbose);
}; };
#endif //FTESTS_JLOADER_H #endif //FTESTS_JLOADER_H

View File

@ -1,16 +1,28 @@
#include "Suite.h" #include "Suite.h"
/*
Suite::Suite( std::string filename ): JSON_Loader()
/* Suite loads a file and deserializes the Unit JSON object to Unit types as a vector member
* Suite { vector<Unit> }
Suite::Suite(): JSON_Loader()
{ {
load_file( filename ); // empty
}; };
void Suite::load_units_file( std::string filename, bool verbose )
{
// will use json_root staging buffer on each run to append to this->units vector as valid units are found.
this->load_json_file( filename, verbose );
// refill the json_root buffer with a json object in the
if ( this->get_serialized( Json::Value jbuf, "units", verbose ) != 0)
{
this->json_root = jbuf;
}
}
int Suite::load_file(std::string filename): JSON_Loader( filename ) int Suite::load_file(std::string filename): JSON_Loader( filename )
{ {
Json::Value raw_units = this->get_root()["units"]; Json::Value raw_units = this->get_serialized("")
for ( int index = 0; index < raw_units.size(); index++ ) 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 ] ) );
@ -20,7 +32,7 @@ int Suite::load_file(std::string filename): JSON_Loader( filename )
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
Unit Suite::get_unit(std::string provided_name) /* Unit Suite::get_unit(std::string provided_name)
* returns a unit from a unitholder object by name * returns a unit from a unitholder object by name
* this will need reworked. maybe should return int, populate a pointer. * this will need reworked. maybe should return int, populate a pointer.
@ -48,3 +60,7 @@ Unit Suite::get_unit(std::string provided_name)
return * returnable; return * returnable;
} }
*/ */
ca

View File

@ -9,15 +9,18 @@
class Suite: public JSON_Loader class Suite: public JSON_Loader
{ {
private: private:
// storage for the definitions we are amassing from the unit definition files
std::vector<Unit> units; std::vector<Unit> units;
public: public:
// constructor // constructor, empty
Suite( std::string filename ); Suite();
int load_file( std::string filename ); // load a unit definitions file and add valid unit definitions to this->units
// returns the unit type identified by name or null void load_units_file( std::string filename );
Unit get_unit(std::string provided_name);
// returns the unit identified by name
void get_unit(Unit & result, std::string provided_name);
}; };
#endif //FTESTS_UNITS_H #endif //FTESTS_UNITS_H

View File

@ -5,7 +5,7 @@
#define FTESTS_LOADERS_H #define FTESTS_LOADERS_H
#include "JSON_Loader.h" #include "JSON_Loader.h"
//#include "Suite.h" #include "Suite.h"
//#include "Plan.h" //#include "Plan.h"
#include "Conf.h" #include "Conf.h"