pushing local
parent
36f34469fb
commit
c8b0872993
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"units_path": "/home/phanes/Development/internal/ftests/conf/units/all_test.units",
|
||||
"plan_path": "/home/phanes/Development/internal/ftests/conf/plans/test.plan"
|
||||
"units_path": "/home/phanes/Development/internal/Examplar/conf/units/all_test.units",
|
||||
"plan_path": "/home/phanes/Development/internal/Examplar/conf/plans/test.plan"
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
"units": [
|
||||
{
|
||||
"name": "independent test",
|
||||
"target": "/home/phanes/tests/test-script-pass.sh",
|
||||
"target": "/bin/pwd",
|
||||
"output": "pass",
|
||||
"rectifier": "/home/phanes/tests/test-script-rectifier.sh",
|
||||
"rectifier": "/bin/pwd",
|
||||
"active": true,
|
||||
"required": true,
|
||||
"rectify": true
|
||||
|
|
|
@ -6,16 +6,14 @@ 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("/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.
|
||||
std::string definitions_file = configuration.get_units_path();
|
||||
|
||||
std::string plan_file = configuration.get_plan_path();
|
||||
// std::cout << definitions_file << std::endl << plan_file << std::endl;
|
||||
|
||||
|
||||
std::cout << definitions_file << std::endl << plan_file << std::endl;
|
||||
|
||||
Suite available_definitions;
|
||||
|
||||
// Suite * unit_definitions = new Suite();
|
||||
|
||||
|
|
|
@ -318,8 +318,7 @@ namespace Json {
|
|||
lastValue_(), commentsBefore_(), features_(features), collectComments_() {
|
||||
}
|
||||
|
||||
bool
|
||||
Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
||||
bool Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
||||
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
|
||||
std::swap(documentCopy, document_);
|
||||
const char* begin = document_.c_str();
|
||||
|
|
|
@ -19,10 +19,10 @@ Conf::Conf( std::string filename ): JSON_Loader()
|
|||
this->load_json_file( filename, true );
|
||||
|
||||
// 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
|
||||
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()
|
||||
|
|
|
@ -70,7 +70,7 @@ void JSON_Loader::load_json_string( std::string input, bool verbose )
|
|||
Json::Reader json_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
|
||||
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();
|
||||
}
|
||||
|
||||
// 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
|
||||
// verbosity flag
|
||||
// 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.
|
||||
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
|
||||
// shouldn't the be handled further up?
|
||||
if ( verbose )
|
||||
{
|
||||
// verbose mode tells the user what key we were looking for.
|
||||
|
|
|
@ -27,10 +27,11 @@ class JSON_Loader
|
|||
void load_json_string( std::string input, bool verbose );
|
||||
|
||||
// return as a JSONCPP serialized object
|
||||
Json::Value as_serialized();
|
||||
std::string as_string();
|
||||
// deprecated -- these aren't really used.
|
||||
// Json::Value as_serialized();
|
||||
// std::string as_string();
|
||||
|
||||
// safely handle key retrieval (if we want it to be safe)
|
||||
int get_key( Json::Value &input, std::string key, bool verbose);
|
||||
// safely handle deserialized type retrieval (if we want it to be safe)
|
||||
int get_serialized(Json::Value &input, std::string key, bool verbose);
|
||||
};
|
||||
#endif //FTESTS_JLOADER_H
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
#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 )
|
||||
{
|
||||
Json::Value raw_units = this->get_root()["units"];
|
||||
Json::Value raw_units = this->get_serialized("")
|
||||
for ( int index = 0; index < raw_units.size(); 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;
|
||||
}
|
||||
|
||||
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
|
||||
* 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;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
ca
|
|
@ -9,15 +9,18 @@
|
|||
class Suite: public JSON_Loader
|
||||
{
|
||||
private:
|
||||
// storage for the definitions we are amassing from the unit definition files
|
||||
std::vector<Unit> units;
|
||||
|
||||
public:
|
||||
// constructor
|
||||
Suite( std::string filename );
|
||||
// constructor, empty
|
||||
Suite();
|
||||
|
||||
int load_file( std::string filename );
|
||||
// returns the unit type identified by name or null
|
||||
Unit get_unit(std::string provided_name);
|
||||
// load a unit definitions file and add valid unit definitions to this->units
|
||||
void load_units_file( std::string filename );
|
||||
|
||||
// returns the unit identified by name
|
||||
void get_unit(Unit & result, std::string provided_name);
|
||||
};
|
||||
|
||||
#endif //FTESTS_UNITS_H
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define FTESTS_LOADERS_H
|
||||
|
||||
#include "JSON_Loader.h"
|
||||
//#include "Suite.h"
|
||||
#include "Suite.h"
|
||||
//#include "Plan.h"
|
||||
#include "Conf.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue