Skip to content

Commit 0f69c4c

Browse files
spencerjacksonEvergreen Agent
authored and
Evergreen Agent
committed
SERVER-47355 Propagate hygienic installation path into shell tests
1 parent 554ec67 commit 0f69c4c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

buildscripts/resmokelib/core/programs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def make_process(*args, **kwargs):
7070
# If installDir is provided, add it early to the path
7171
if config.INSTALL_DIR is not None:
7272
path.append(config.INSTALL_DIR)
73+
env_vars["INSTALL_DIR"] = config.INSTALL_DIR
7374

7475
path.append(env_vars.get("PATH", os.environ.get("PATH", "")))
7576

src/mongo/shell/shell_utils_extended.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,28 @@ BSONObj readDumpFile(const BSONObj& a, void*) {
435435
return builder.obj();
436436
}
437437

438+
BSONObj shellGetEnv(const BSONObj& a, void*) {
439+
uassert(46712006,
440+
"_getEnv() takes one argument: the name of the environment variable",
441+
a.nFields() == 1 && a.firstElementType() == String);
442+
const auto envName = a.firstElement().String();
443+
std::string result{};
444+
#ifndef _WIN32
445+
auto envPtr = getenv(envName.c_str());
446+
if (envPtr) {
447+
result = std::string(envPtr);
448+
}
449+
#else
450+
auto envPtr = _wgetenv(toNativeString(envName.c_str()).c_str());
451+
if (envPtr) {
452+
result = toUtf8String(envPtr);
453+
}
454+
#endif
455+
456+
return BSON("" << result.c_str());
457+
}
458+
459+
438460
} // namespace
439461

440462
void installShellUtilsExtended(Scope& scope) {
@@ -454,6 +476,7 @@ void installShellUtilsExtended(Scope& scope) {
454476
scope.injectNative("umask", changeUmask);
455477
scope.injectNative("getFileMode", getFileMode);
456478
scope.injectNative("_readDumpFile", readDumpFile);
479+
scope.injectNative("_getEnv", shellGetEnv);
457480
}
458481

459482
} // namespace shell_utils

0 commit comments

Comments
 (0)