aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/common
diff options
context:
space:
mode:
authorzhukoff-pavel <zhukoff-pavel@yandex-team.com>2023-05-18 16:08:11 +0300
committerzhukoff-pavel <zhukoff-pavel@yandex-team.com>2023-05-18 16:08:11 +0300
commit609d4c8138a6605de6fbc333e865b36acdb5cee6 (patch)
tree6428629679edb29de98b617ccb2cdb43bc22ec34 /library/cpp/testing/common
parent76f1d9f25a25d001f50b32113a5cc8f488d9d20a (diff)
downloadydb-609d4c8138a6605de6fbc333e865b36acdb5cee6.tar.gz
Setup test env.vars from test.context during test binary initialization cpp
Diffstat (limited to 'library/cpp/testing/common')
-rw-r--r--library/cpp/testing/common/env.cpp19
-rw-r--r--library/cpp/testing/common/env.h1
2 files changed, 19 insertions, 1 deletions
diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp
index 77c6b0d90b..6585de8584 100644
--- a/library/cpp/testing/common/env.cpp
+++ b/library/cpp/testing/common/env.cpp
@@ -170,11 +170,12 @@ namespace NPrivate {
TestOutputRamDrivePath = "";
GdbPath = "";
CoreSearchFile = "";
+ EnvFile = "";
TestParameters.clear();
GlobalResources.clear();
const TString contextFilename = GetEnv("YA_TEST_CONTEXT_FILE");
- if (contextFilename) {
+ if (contextFilename && TFsPath(contextFilename).Exists()) {
NJson::TJsonValue context;
NJson::ReadJsonTree(TFileInput(contextFilename).ReadAll(), &context);
@@ -238,6 +239,22 @@ namespace NPrivate {
if (value) {
CoreSearchFile = value->GetStringSafe("");
}
+
+ value = context.GetValueByPath("internal.env_file");
+ if (value) {
+ EnvFile = value->GetStringSafe("");
+ if (TFsPath(EnvFile).Exists()) {
+ TFileInput file(EnvFile);
+ NJson::TJsonValue envVar;
+ TString ljson;
+ while (file.ReadLine(ljson) > 0) {
+ NJson::ReadJsonTree(ljson, &envVar);
+ for (const auto& entry : envVar.GetMap()) {
+ SetEnv(entry.first, entry.second.GetStringSafe(""));
+ }
+ }
+ }
+ }
}
if (!YtHddPath) {
diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h
index 6dbef4959b..6cd840442f 100644
--- a/library/cpp/testing/common/env.h
+++ b/library/cpp/testing/common/env.h
@@ -78,6 +78,7 @@ namespace NPrivate {
TString TestOutputRamDrivePath;
TString GdbPath;
TString CoreSearchFile;
+ TString EnvFile;
std::unordered_map<TString, TString> TestParameters;
std::unordered_map<TString, TString> GlobalResources;
};