diff --git a/conf/config.json b/conf/config.json index 34b6bd1..709087a 100644 --- a/conf/config.json +++ b/conf/config.json @@ -3,5 +3,6 @@ "execution_context": "/home/phanes/development/internal/Examplar/conf/", "units_path": "units/all_test.units", "plan_path": "plans/test.plan", - "config_version": "2" + "config_version": "3", + "env_vars_file": "Examplar.variables" } diff --git a/src/loaders/Conf.cpp b/src/loaders/Conf.cpp index 94e18ba..4dae71c 100644 --- a/src/loaders/Conf.cpp +++ b/src/loaders/Conf.cpp @@ -114,6 +114,14 @@ Conf::Conf( std::string filename, bool verbose ): JSON_Loader() } else { this->execution_context_literal = this->execution_context.asString(); } + + if ( this->get_serialized(this->env_vars_file, "env_vars_file", true) != 0 ) + { + throw ConfigLoadException("env_vars_file is not set in the config file supplied: " + filename); + } + + + }; /// Conf::has_context_override - Specifies whether or not the override context function is enabled in the conf file. @@ -138,3 +146,8 @@ void Conf::set_execution_context( std::string execution_context ) { this->execution_context_literal = execution_context; } + +std::string Conf::get_env_vars_file() +{ + return this->env_vars_file.asString(); +} \ No newline at end of file diff --git a/src/loaders/Conf.h b/src/loaders/Conf.h index fb0b41a..44598b6 100644 --- a/src/loaders/Conf.h +++ b/src/loaders/Conf.h @@ -26,7 +26,7 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -# define IMPL_CONFIG_VERSION 2 +# define IMPL_CONFIG_VERSION 3 # define VERSION_STRING STRINGIZE(IMPL_CONFIG_VERSION) class Conf: public JSON_Loader @@ -36,6 +36,7 @@ private: Json::Value units_path; Json::Value execution_context; Json::Value config_version; + Json::Value env_vars_file; // flag to indicate if execution context should be overriden in config file // if set to true Examplar should use whats in the config file for current working directory @@ -53,8 +54,11 @@ public: bool has_context_override(); std::string get_execution_context(); + void set_execution_context( std::string ); + std::string get_env_vars_file(); + }; #endif //FTESTS_CONF_H diff --git a/src/loaders/Task.cpp b/src/loaders/Task.cpp index c8257f2..ec9cbba 100644 --- a/src/loaders/Task.cpp +++ b/src/loaders/Task.cpp @@ -200,11 +200,12 @@ void Task::execute( Conf * configuration, bool verbose ) // if we're in verbose mode, do some verbose things if ( verbose ) { - +/* infostring = std::ostringstream(); infostring << "\tUsing unit \"" << task_name << "\"." << std::endl; syslog( LOG_INFO, infostring.str().c_str() ); std::cout << infostring.str(); +*/ // check if context override if ( configuration->has_context_override() ) @@ -224,7 +225,8 @@ void Task::execute( Conf * configuration, bool verbose ) } // a[0] execute target - int return_code = Sproc::execute( target_command ); + // TODO revise variable sourcing strategy + int return_code = Sproc::execute( "source " + configuration->get_env_vars_file() + " && " + target_command ); // ********************************************** // d[0] Error Code Check