diff --git a/src/libutil/current-process.cc b/src/libutil/current-process.cc index 10522d5ae..c07ed8371 100644 --- a/src/libutil/current-process.cc +++ b/src/libutil/current-process.cc @@ -7,6 +7,7 @@ #include "nix/util/file-system.hh" #include "nix/util/processes.hh" #include "nix/util/signals.hh" +#include "nix/util/environment-variables.hh" #include #ifdef __APPLE__ @@ -66,14 +67,16 @@ void setStackSize(size_t stackSize) if (getrlimit(RLIMIT_STACK, &limit) == 0 && static_cast(limit.rlim_cur) < stackSize) { savedStackSize = limit.rlim_cur; if (limit.rlim_max < static_cast(stackSize)) { - logger->log( - lvlWarn, - HintFmt( - "Stack size hard limit is %1%, which is less than the desired %2%. If possible, increase the hard limit, e.g. with 'ulimit -Hs %3%'.", - limit.rlim_max, - stackSize, - stackSize / 1024) - .str()); + if (getEnv("_NIX_TEST_NO_ENVIRONMENT_WARNINGS") != "1") { + logger->log( + lvlWarn, + HintFmt( + "Stack size hard limit is %1%, which is less than the desired %2%. If possible, increase the hard limit, e.g. with 'ulimit -Hs %3%'.", + limit.rlim_max, + stackSize, + stackSize / 1024) + .str()); + } } auto requestedSize = std::min(static_cast(stackSize), limit.rlim_max); limit.rlim_cur = requestedSize; diff --git a/tests/functional/common/vars.sh b/tests/functional/common/vars.sh index ed4b47727..d4d917dae 100644 --- a/tests/functional/common/vars.sh +++ b/tests/functional/common/vars.sh @@ -49,6 +49,9 @@ if ! isTestOnNixOS; then fi export _NIX_IN_TEST=$TEST_ROOT/shared export _NIX_TEST_NO_LSOF=1 + # Suppress warnings that depend on the test environment (e.g., ulimit warnings) + # to avoid non-deterministic test failures in golden tests + export _NIX_TEST_NO_ENVIRONMENT_WARNINGS=1 export NIX_REMOTE=${NIX_REMOTE_-} fi # ! isTestOnNixOS