removed output checks from data model and from implementation.

prepared to implement STD{IN,OUT,ERR} piping for subprocess execution.  Hoping to maintain compatibility with curses dialogs.
master
Phanes 2017-12-01 01:13:30 -05:00
parent 3bc8908d65
commit 8545264a92
5 changed files with 32 additions and 46 deletions

View File

@ -2,36 +2,32 @@
"units": [
{
"name": "independent test 1",
"target": "/bin/pwd",
"output": "pass",
"rectifier": "/bin/pwd",
"target": "/usr/bin/true",
"rectifier": "/usr/bin/true",
"active": true,
"required": true,
"rectify": true
},
{
"name": "independent test 2",
"target": "/bin/pwd",
"output": "pass",
"rectifier": "/bin/pwd",
"target": "/usr/bin/false",
"rectifier": "/usr/bin/true",
"active": true,
"required": true,
"rectify": true
"rectify": false
},
{
"name": "A DEFINITION THAT IS NOT USED",
"target": "/bin/pwd",
"output": "pass",
"rectifier": "/bin/pwd",
"target": "/usr/bin/false",
"rectifier": "/usr/bin/true",
"active": true,
"required": true,
"rectify": true
"rectify": false
},
{
"name": "dependent test",
"target": "/home/phanes/tests/test-script-pass.sh",
"output": "pass",
"rectifier": "/home/phanes/tests/test-script-rectifier.sh",
"target": "/usr/bin/false",
"rectifier": "/usr/bin/true",
"active": true,
"required": true,
"rectify": false

View File

@ -97,15 +97,22 @@ void Task::execute( bool verbose )
std::cout << "\t Executing target \"" << this->definition.get_target() << "\"." << std::endl;
}
ExecutionInput execIn;
Execution Result;
std::string executionString = this->definition.get_target();
std::string rectifierString = this->definition.get_rectifier();
execIn.executionString = this->definition.get_target();
int return_code = Sproc::execute( executionString );
int execution_status = Sproc::execute( execIn, Result );
if ( execution_status )
if ( return_code )
{
std::cout << std::endl << "STDOUT:" << std::endl<< Result.STDOUT << std::endl;
std::cout << "Process failed with exit code " << return_code << "." << std::endl;
std::cout << "Performing rectification: " << rectifierString << "." << std::endl;
int rectifier_error = Sproc::execute( rectifierString );
if ( rectifier_error )
{
std::cout << "Designated rectification script failed with error " << rectifier_error << "." << std::endl;
}
}
}

View File

@ -48,9 +48,6 @@ int Unit::load_root(Json::Value loader_root)
if ( loader_root.isMember("target") )
{ this->target = loader_root.get("target", errmsg).asString(); } else throw Unit_DataStructureException();
if ( loader_root.isMember("output") )
{ this->output = loader_root.get("output", errmsg).asString(); } else throw Unit_DataStructureException();
if ( loader_root.isMember("rectifier") )
{ this->rectifier = loader_root.get("rectifier", errmsg).asString(); } else throw Unit_DataStructureException();

View File

@ -1,7 +1,10 @@
#include "Sproc.h"
int Sproc::execute(ExecutionInput input, Execution &output)
int Sproc::execute( std::string input )
{
output.STDOUT = "it worked";
std::cout << std::endl << "made it to subprocess execution but not implemented yet" << std::endl << std::endl;
return EXIT_SUCCESS;
}

View File

@ -1,32 +1,15 @@
#ifndef FTESTS_SPROC_H
#define FTESTS_SPROC_H
#include "string"
struct ExecutionInput {
std::string executionString;
// std::string STDIN;
// std::vector<KeyValuePair> EnvironmentVariables;
};
struct Execution {
//input
ExecutionInput input;
// output
int return_code;
std::string STDOUT;
std::string STDERR;
};
#include <string>
#include <iostream>
// executes a subprocess and captures STDOUT, STDERR, and return code.
// should be able to recieve path of binary to be executed as well as any parameters
class Sproc {
public:
// call the object. returnvalue is enum representing external execution attempt not binary exit code
static int execute( ExecutionInput input, Execution & output );
static int execute( std::string input );
};
#endif //FTESTS_SPROC_H