-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverlord.cc
More file actions
76 lines (66 loc) · 2.25 KB
/
overlord.cc
File metadata and controls
76 lines (66 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include "overlord.h"
overlord::overlord(std::string filen){
filename = filen;
}
overlord::~overlord(){
subroutines.clear();
test_files.clear();
}
void overlord::read_tests(){
boost::property_tree::ptree pt;
boost::property_tree::read_json(filename, pt);
BOOST_FOREACH( boost::property_tree::ptree::value_type &v, pt.get_child("runtime") ){
string env, name, args;
BOOST_FOREACH(boost::property_tree::ptree::value_type& itemPair, v.second){
if ( itemPair.first == "env" ){
env = itemPair.second.get_value<std::string>();
}
else if ( itemPair.first == "script_name" ){
name = itemPair.second.get_value<std::string>();
}
else if ( itemPair.first == "arguments" ) {
args = itemPair.second.get_value<std::string>();
}
}
minion m(env, name, args);
subroutines.push_back(m);
}
}
void overlord::read_test_files(){
boost::property_tree::ptree pt;
boost::property_tree::read_json(filename, pt);
BOOST_FOREACH( boost::property_tree::ptree::value_type &v, pt.get_child("testFiles") ){
test_files.push_back( v.second.get_value<std::string>() );
}
}
void overlord::read_json(){
read_tests();
read_test_files();
}
void overlord::run_subprocess(){
for ( std::vector<minion>::iterator test = subroutines.begin() ; test != subroutines.end() ; ++test ){
// Check if "%s" exists within the execution string. If it doesn't, this is a run-once execution.
if ( find_boost_format_string( test->to_string() ) != std::string::npos ){
for ( std::vector<std::string>::iterator file = test_files.begin() ; file != test_files.end() ; ++file ){
test->execute( *file );
}
}
else
test->execute();
}
}
std::size_t overlord::find_boost_format_string(std::string formater){
return formater.find("%s");
}