diff --git a/test/tap/tap/command_line.cpp b/test/tap/tap/command_line.cpp index 6764695b2..a667bb9bb 100644 --- a/test/tap/tap/command_line.cpp +++ b/test/tap/tap/command_line.cpp @@ -112,58 +112,54 @@ int CommandLine::getEnv() { std::string dir_path = exe_path.substr(0, exe_path.find_last_of('/')); std::string dir_name = dir_path.substr(dir_path.find_last_of('/') + 1); - diag("reading: %s", (dir_path + "/.env").c_str()); + diag("loading: %s", (dir_path + "/.env").c_str()); env.load_dotenv((dir_path + "/.env").c_str(), true); - diag("reading: %s", (dir_path + "/" + dir_name + ".env").c_str()); + diag("loading: %s", (dir_path + "/" + dir_name + ".env").c_str()); env.load_dotenv((dir_path + "/" + dir_name + ".env").c_str(), true); - diag("reading: %s", (exe_path + ".env").c_str()); + diag("loading: %s", (exe_path + ".env").c_str()); env.load_dotenv((exe_path + ".env").c_str(), true); } value=getenv("TAP_HOST"); - if(!value) return -1; - replace_str_field(&this->host, value); + if (value) + replace_str_field(&this->host, value); value=getenv("TAP_USERNAME"); - if(!value) return -1; - replace_str_field(&this->username, value); + if (value) + replace_str_field(&this->username, value); value=getenv("TAP_PASSWORD"); - if(!value) return -1; - replace_str_field(&this->password, value); + if (value) + replace_str_field(&this->password, value); value=getenv("TAP_ADMINUSERNAME"); - if (value) { + if (value) replace_str_field(&this->admin_username, value); - } value=getenv("TAP_ADMINPASSWORD"); - if (value) { + if (value) replace_str_field(&this->admin_password, value); - } - int env_port=0; + int env_port = 0; value=getenv("TAP_PORT"); - if(value) - env_port=strtol(value, NULL, 10); - else - env_port=6033; - if(env_port>0 && env_port<65536) - port=env_port; + if (value) { + env_port = strtol(value, NULL, 10); + if (env_port>0 && env_port<65536) + port = env_port; + } value=getenv("TAP_ADMINPORT"); - if(value) - env_port=strtol(value, NULL, 10); - else - env_port=6032; - if(env_port>0 && env_port<65536) - admin_port=env_port; + if (value) { + env_port = strtol(value, NULL, 10); + if (env_port>0 && env_port<65536) + admin_port = env_port; + } value=getenv("TAP_WORKDIR"); - if(!value) return -1; - replace_str_field(&this->workdir, value); + if (value) + replace_str_field(&this->workdir, value); value=getenv("TAP_CLIENT_FLAGS"); if (value) { @@ -172,7 +168,7 @@ int CommandLine::getEnv() { const char* errmsg { NULL }; - if (env_c_flags == 0 && value == end) { + if (env_c_flags == 0 && value == end) { errmsg = "Invalid string to parse"; } else if (env_c_flags == ULONG_MAX && errno == ERANGE) { errmsg = strerror(errno); diff --git a/test/tap/tap/command_line.h b/test/tap/tap/command_line.h index 4847b460d..3d3e8982a 100644 --- a/test/tap/tap/command_line.h +++ b/test/tap/tap/command_line.h @@ -17,13 +17,13 @@ class CommandLine { char* host = strdup("127.0.0.1"); char* username = strdup("root"); - char* password = strdup(""); + char* password = strdup("root"); char* admin_username = strdup("admin"); char* admin_password = strdup("admin"); int port = 6033; int admin_port = 6032; - char* workdir = strdup("./tests/"); + char* workdir = strdup("./"); uint64_t client_flags = 0; int getEnv(); diff --git a/test/tap/tests/envvars-t.cpp b/test/tap/tests/envvars-t.cpp index 568f777bc..eb9f67d0c 100644 --- a/test/tap/tests/envvars-t.cpp +++ b/test/tap/tests/envvars-t.cpp @@ -4,12 +4,13 @@ #include "tap.h" #include "command_line.h" -int main() { +int main(int argc, char** argv) { CommandLine cl; char* value = NULL; // this test checks the env file loading mechanism implemented in tap/command_line.cpp:CommandLine::getEnv() + // foldername/.env - enviroment vars for whole folder // foldername/foldername.env - enviroment vars for whole folder // foldername/testname-t.env - enviroment vars only for testname-t @@ -17,13 +18,11 @@ int main() { // echo 'TAP_ENV_VAR1=.env' > .env // echo 'TAP_ENV_VAR2=tests.env' > tests.env // echo 'TAP_ENV_VAR3=envvars-t.env' > envvars-t.env - // echo 'TAP_ENV_VAR4=envvars.env' > envvars.env -// if (cl.getEnv()) { -// diag("Failed to get the required environmental variables."); -// return -1; -// } - cl.getEnv(); + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return -1; + } plan(3);