From ce0df85d80aaf45a6b47a07a7481180669e22816 Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 4 Apr 2021 21:30:02 +0300 Subject: [PATCH] [tests] Do cleanup. Signed-off-by: vng --- generator/generator_tests/speed_cameras_test.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/generator/generator_tests/speed_cameras_test.cpp b/generator/generator_tests/speed_cameras_test.cpp index edfe9857d8..81e89c6028 100644 --- a/generator/generator_tests/speed_cameras_test.cpp +++ b/generator/generator_tests/speed_cameras_test.cpp @@ -37,6 +37,7 @@ #include "base/logging.hpp" #include "base/macros.hpp" #include "base/math.hpp" +#include "base/scope_guard.hpp" #include "defines.hpp" @@ -154,7 +155,15 @@ void TestSpeedCameraSectionBuilding(string const & osmContent, CameraMap const & // Create test dir. string const testDirFullPath = base::JoinPath(tmpDir, kTestDir); - FORCE_USE_VALUE(Platform::MkDir(testDirFullPath)); + if (!Platform::MkDirChecked(testDirFullPath)) + { + TEST(false, ("Can't create tmp dir", testDirFullPath)); + return; + } + SCOPE_GUARD(cleanupDirGuard, [&testDirFullPath]() + { + UNUSED_VALUE(Platform::RmDirRecursively(testDirFullPath)); + }); string const osmRelativePath = base::JoinPath(kTestDir, kOsmFileName); ScopedFile const osmScopedFile(osmRelativePath, osmContent); @@ -174,7 +183,7 @@ void TestSpeedCameraSectionBuilding(string const & osmContent, CameraMap const & TEST(GenerateIntermediateData(genInfo), ("Cannot generate intermediate data for speed cam")); // Building empty mwm. - LocalCountryFile country(base::JoinPath(tmpDir, kTestDir), CountryFile(kTestMwm), 0 /* version */); + LocalCountryFile country(testDirFullPath, CountryFile(kTestMwm), 0 /* version */); string const mwmRelativePath = base::JoinPath(kTestDir, kTestMwm + DATA_FILE_EXTENSION); ScopedFile const scopedMwm(mwmRelativePath, ScopedFile::Mode::Create);