rex/src/loaders/Unit.h

61 lines
2.0 KiB
C
Raw Normal View History

2017-06-20 06:06:33 +00:00
/* Unit.h
* Unit is a type that represents a safely deserialized JSON object which defines what actions are taken as Examplar
* iterates through it's Tasks in it's given Plan. They only define the behaviour on execution, while the tasks define
* which Units are executed and in what order (and which Units a given Task depends on.
*/
#ifndef FTESTS_UNIT_H
#define FTESTS_UNIT_H
#include <string>
#include "../json/json.h"
2017-06-20 06:06:33 +00:00
#include "JSON_Loader.h"
2017-06-20 06:06:33 +00:00
class Unit: JSON_Loader
{
private:
2017-06-20 06:06:33 +00:00
// the name of the test
std::string name;
2017-06-20 06:06:33 +00:00
// the path of the executable this test executes when run
std::string target;
2017-06-20 06:06:33 +00:00
// the desired output
// poll: would an empty value be good to indicate to rely solely on zero/non-zero exit code?
std::string output;
2017-06-20 06:06:33 +00:00
// the path of the executable this test runs when the target executable fails to produce output or a 0 exit code.
std::string rectifier;
2017-06-20 06:06:33 +00:00
// an indicator of whether the test is active or not
// this is used as a way to give definers a way to force executors to edit arbitrary fields or prevent
// execution of potentially dangerous or intrusive tests
std::string active;
2017-06-20 06:06:33 +00:00
// an indicator of whether or not this test is required to pass.
// intended to be used as a flag to halt execution of further tests on failure
std::string required;
2017-06-20 06:06:33 +00:00
// indicator of whether the rectifier executable should be run on test failures.
// if rectifier exits on non-zero return code, it should be trigger the behaviour indicated by required
std::string rectify;
public:
Unit();
2017-06-20 06:06:33 +00:00
// loads a serialized jason::value object as a unit
int load_root( Json::Value loader_root );
2017-06-20 06:06:33 +00:00
// loads a string as a json string and deserializes that.
int load_string( std::string json_val );
// getters
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();
};
#endif //FTESTS_UNIT_H