diff --git a/examplar.cpp b/examplar.cpp index 551d499..7b477c6 100644 --- a/examplar.cpp +++ b/examplar.cpp @@ -110,7 +110,7 @@ int main( int argc, char * argv[] ) std::cout << "Verbosity is INFO." << std::endl; } - Logger slog = Logger( L_LEVEL, "Examplar" ); + Logger slog = Logger( L_LEVEL, "examplar" ); // 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. diff --git a/src/loaders/abstract/Conf.cpp b/src/loaders/abstract/Conf.cpp index a8f3f01..2a70f7a 100644 --- a/src/loaders/abstract/Conf.cpp +++ b/src/loaders/abstract/Conf.cpp @@ -66,7 +66,7 @@ protected: /// TODO Expand to detect when a directory path is supplied for units_path or plan_path and import all Tasks and Units. /// /// \param filename - The filename to load the configuration from. -Conf::Conf( std::string filename, int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "examplar::test" ) +Conf::Conf( std::string filename, int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "e_conf" ) { this->LOG_LEVEL = LOG_LEVEL; @@ -122,6 +122,18 @@ Conf::Conf( std::string filename, int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slo throw ConfigLoadException("env_vars_file is not set in the config file supplied: " + filename); } + this->env_vars_file_literal = this->execution_context_literal + "/" + this->env_vars_file.asString(); + + if ( exists( this->env_vars_file_literal ) ) + { + this->slog.log( E_DEBUG, "Environment variables file exists: '" + this->env_vars_file_literal + "'." ); + } else { + this->slog.log( E_FATAL, "Variables file does not exist: '" + this->env_vars_file_literal + "'."); + throw ConfigLoadException( "env_vars_file points to an incorrect path." ); + } + + + }; /// Conf::has_context_override - Specifies whether or not the override context function is enabled in the conf file. @@ -148,5 +160,5 @@ void Conf::set_execution_context( std::string execution_context ) std::string Conf::get_env_vars_file() { - return this->env_vars_file.asString(); + return this->env_vars_file_literal; } diff --git a/src/loaders/abstract/Conf.h b/src/loaders/abstract/Conf.h index c41b31d..ae54f8d 100644 --- a/src/loaders/abstract/Conf.h +++ b/src/loaders/abstract/Conf.h @@ -23,7 +23,7 @@ #include "../low_level/JSON_Loader.h" #include #include "../../Logger/Logger.h" - +#include "../misc/helpers.h" #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) @@ -39,6 +39,8 @@ private: Json::Value config_version; Json::Value env_vars_file; + std::string env_vars_file_literal; + // 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 // if set to false, Examplar should use the current working directory at time of execution diff --git a/src/loaders/abstract/Plan.cpp b/src/loaders/abstract/Plan.cpp index 947cf50..5c35ce1 100644 --- a/src/loaders/abstract/Plan.cpp +++ b/src/loaders/abstract/Plan.cpp @@ -120,7 +120,7 @@ protected: /// Plan::Plan() - Constructor for Plan class. A Plan is a managed container for a Task vector. These tasks reference /// Units that are defined in the Units files (Suite). If Units are definitions, Tasks are selections of those /// definitions to execute, and if Units together form a Suite, Tasks together form a Plan. -Plan::Plan( Conf * configuration, int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "examplar::plan" ) +Plan::Plan( Conf * configuration, int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "e_plan" ) { this->configuration = configuration; this->LOG_LEVEL = LOG_LEVEL; diff --git a/src/loaders/abstract/Suite.cpp b/src/loaders/abstract/Suite.cpp index 0738b0e..f89b37a 100644 --- a/src/loaders/abstract/Suite.cpp +++ b/src/loaders/abstract/Suite.cpp @@ -79,7 +79,7 @@ protected: /// human processes to allow modularly developed profiles of test suites. As inferred, Unit is expected to be one of /// the two types that are only instantiated once per application run, though it is designed to be used more than once /// if the implementor so desires. -Suite::Suite( int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "examplar::suite" ) +Suite::Suite( int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "e_suite" ) { this->LOG_LEVEL; } diff --git a/src/loaders/abstract/Task.cpp b/src/loaders/abstract/Task.cpp index d3b5441..1ba6e2c 100644 --- a/src/loaders/abstract/Task.cpp +++ b/src/loaders/abstract/Task.cpp @@ -80,7 +80,7 @@ protected: /// Task::Task() - Constructor for the Task class. The Task is the building block of a Plan indicating of which Unit to /// execute, and its dependencies on other units to have already been completed successfully. Task::Task( int LOG_LEVEL ): - slog( LOG_LEVEL, "examplar::task" ), + slog( LOG_LEVEL, "e_task" ), definition( LOG_LEVEL ) { // it hasn't executed yet. @@ -180,7 +180,7 @@ void Task::execute( Conf * configuration ) // get the name std::string task_name = this->definition.get_name(); - this->slog.log( E_DEBUG, "\tUsing unit: \"" + task_name + "\"." ); + this->slog.log( E_DEBUG, "Using unit: \"" + task_name + "\"." ); // END PREWORK // get the target execution command diff --git a/src/loaders/abstract/Unit.cpp b/src/loaders/abstract/Unit.cpp index 6079622..88fcfa2 100644 --- a/src/loaders/abstract/Unit.cpp +++ b/src/loaders/abstract/Unit.cpp @@ -48,7 +48,7 @@ class Unit_DataStructureException: public std::runtime_error { public: /// required, which is used as a flag to halt or continue if rectifier does not heal the system in such a way that /// target can run successfully. /// rectify, which is used as a flag to determine in the rectifier runs. -Unit::Unit( int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "examplar::unit" ) +Unit::Unit( int LOG_LEVEL ): JSON_Loader( LOG_LEVEL ), slog( LOG_LEVEL, "e_unit" ) { this->LOG_LEVEL; } diff --git a/src/loaders/low_level/JSON_Loader.cpp b/src/loaders/low_level/JSON_Loader.cpp index 57e49c1..ec68494 100644 --- a/src/loaders/low_level/JSON_Loader.cpp +++ b/src/loaders/low_level/JSON_Loader.cpp @@ -38,7 +38,7 @@ class JSON_Loader_InvalidJSON: public std::runtime_error { public: /// JSON_Loader::JSON_Loader - Constructor for JSON_Loader base class. Simply inits to an unpopulated state. /// /// The JSON_Loader type is a base type. It is meant to provide the functionalities shared between Suite and Plan. -JSON_Loader::JSON_Loader( int LOG_LEVEL ): slog( LOG_LEVEL, "examplar::json_loader" ) +JSON_Loader::JSON_Loader( int LOG_LEVEL ): slog( LOG_LEVEL, "e_json" ) { this->populated = false; this->LOG_LEVEL = LOG_LEVEL; diff --git a/test/config.json b/test/config.json index 8f6761e..37909dc 100644 --- a/test/config.json +++ b/test/config.json @@ -4,5 +4,5 @@ "units_path": "units/all_test.units", "plan_path": "plans/test.plan", "config_version": "3", - "env_vars_file": "Examplar.variables" + "env_vars_file": "examplar.variables" } diff --git a/test/examplar.variables b/test/examplar.variables new file mode 100644 index 0000000..d10a126 --- /dev/null +++ b/test/examplar.variables @@ -0,0 +1 @@ +echo "This is output from loading the variables file." \ No newline at end of file diff --git a/test/units/all_test.units b/test/units/all_test.units index 41fac62..89f167e 100644 --- a/test/units/all_test.units +++ b/test/units/all_test.units @@ -20,8 +20,8 @@ "name": "A DEFINITION THAT IS NOT USED", "target": "/usr/bin/dialog --yesno test 50 50", "rectifier": "/usr/bin/false", - "active": true, - "required": true, + "active": false, + "required": false, "rectify": true }, {