unotest/source/cpp/directories.cxx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
New commits: commit a5ea37cbc5e61a166320a44cbb45926eb2711045 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jul 16 11:10:40 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Jul 16 09:43:17 2025 +0200 Use osl_getEnvironment to simplify Directories initialization Change-Id: Ie2bc87fac14ee60972c1f8ffc70bfa3c45f11de7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187940 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/unotest/source/cpp/directories.cxx b/unotest/source/cpp/directories.cxx index 5d2c31929458..d4e1f8e1438f 100644 --- a/unotest/source/cpp/directories.cxx +++ b/unotest/source/cpp/directories.cxx @@ -11,6 +11,7 @@ #include <cppunit/TestAssert.h> #include <osl/file.hxx> +#include <osl/process.h> #include <unotest/directories.hxx> namespace @@ -30,16 +31,11 @@ OUString getFileURLFromSystemPath(OUString const& path) test::Directories::Directories() { - const char* pSrcRoot = getenv("SRC_ROOT"); - CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr); - CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot[0] != 0); - const char* pWorkdirRoot = getenv("WORKDIR_FOR_BUILD"); - CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr); - CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot[0] != 0); - m_aSrcRootPath = OUString::createFromAscii(pSrcRoot); + osl_getEnvironment(u"SRC_ROOT"_ustr.pData, &m_aSrcRootPath.pData); + CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", !m_aSrcRootPath.isEmpty()); + osl_getEnvironment(u"WORKDIR_FOR_BUILD"_ustr.pData, &m_aWorkdirRootPath.pData); + CPPUNIT_ASSERT_MESSAGE("WORKDIR_FOR_BUILD env variable not set", !m_aWorkdirRootPath.isEmpty()); m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath); - - m_aWorkdirRootPath = OUString::createFromAscii(pWorkdirRoot); m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath); }