From a7d94b9d5a4cf31a23a0a91a34890d2e73edb97e Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Wed, 22 Oct 2025 22:18:36 -0500 Subject: [PATCH 1/2] Clean up temporary home directory to make tests more robust Signed-off-by: Addisu Z. Taddese --- test/helpers/EnvTestFixture.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/helpers/EnvTestFixture.hh b/test/helpers/EnvTestFixture.hh index f61f0a3b6a..d052f757c4 100644 --- a/test/helpers/EnvTestFixture.hh +++ b/test/helpers/EnvTestFixture.hh @@ -48,6 +48,8 @@ class InternalFixture : public TestType // Documentation inherited protected: void TearDown() override { + // Clean up fake home directory so that subsequent tests run on a clean slate. + common::removeAll(this->kFakeHome); // Restore $HOME EXPECT_TRUE(common::setenv(GZ_HOMEDIR, this->realHome.c_str())); } From aac799eec52af97d54533794a977dd9bc26728a8 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 23 Oct 2025 10:51:10 -0500 Subject: [PATCH 2/2] Remove expectation that auto_default.log will exist This file only exists if the GUI has run. Since each test now starts with a clean ".gz" directory, this file will not exist when this test runs. Signed-off-by: Addisu Z. Taddese --- test/integration/log_system.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/test/integration/log_system.cc b/test/integration/log_system.cc index a2335cae56..10775f4e1f 100644 --- a/test/integration/log_system.cc +++ b/test/integration/log_system.cc @@ -331,12 +331,6 @@ TEST_F(LogSystemTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(LogDefaults)) std::string(PROJECT_SOURCE_PATH), "test", "worlds", "log_record_dbl_pendulum.sdf"); - // Change environment variable so that test files aren't written to $HOME - std::string homeOrig; - common::env(GZ_HOMEDIR, homeOrig); - std::string homeFake = common::joinPaths(this->logsDir, "default"); - EXPECT_TRUE(common::setenv(GZ_HOMEDIR, homeFake.c_str())); - // Test case 1: // No path specified on command line. This does not go through // gz.cc, recording should take place in the `.gz` directory @@ -359,10 +353,8 @@ TEST_F(LogSystemTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(LogDefaults)) recordServer.Run(true, 200, false); } - // We should expect to see "auto_default.log" and "state.tlog" + // We should expect to see "state.tlog" EXPECT_FALSE(gzLogDirectory().empty()); - EXPECT_TRUE(common::exists( - common::joinPaths(gzLogDirectory(), "auto_default.log"))); EXPECT_TRUE(common::exists( common::joinPaths(gzLogDirectory(), "state.tlog"))); @@ -380,7 +372,7 @@ TEST_F(LogSystemTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(LogDefaults)) // should be recorded here. // Store number of files before running - auto logPath = common::joinPaths(homeFake.c_str(), ".gz", "sim", + auto logPath = common::joinPaths(this->kFakeHome, ".gz", "sim", "log"); int nEntries = entryCount(logPath); std::vector entriesBefore; @@ -420,9 +412,6 @@ TEST_F(LogSystemTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(LogDefaults)) // Remove artifacts. Recreate new directory this->RemoveLogsDir(); #endif - - // Revert environment variable after test is done - EXPECT_TRUE(common::setenv(GZ_HOMEDIR, homeOrig.c_str())); } /////////////////////////////////////////////////