<commit_before>#include "search/search_tests_support/test_mwm_builder.hpp"

#include "search/search_tests_support/test_feature.hpp"

#include "indexer/data_header.hpp"
#include "indexer/features_offsets_table.hpp"
#include "indexer/index_builder.hpp"
#include "indexer/search_index_builder.hpp"

#include "generator/feature_builder.hpp"
#include "generator/feature_generator.hpp"
#include "generator/feature_sorter.hpp"

#include "platform/local_country_file.hpp"

#include "base/logging.hpp"

#include "defines.hpp"

namespace search
{
namespace tests_support
{
TestMwmBuilder::TestMwmBuilder(platform::LocalCountryFile & file, feature::DataHeader::MapType type)
    : m_file(file),
      m_type(type),
      m_collector(
          make_unique<feature::FeaturesCollector>(file.GetPath(MapOptions::Map) + EXTENSION_TMP))
{
}

TestMwmBuilder::~TestMwmBuilder()
{
  if (m_collector)
    Finish();
  CHECK(!m_collector, ("Features weren't dumped on disk."));
}

void TestMwmBuilder::Add(TestFeature const & feature)
{
  CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
  FeatureBuilder1 fb;
  feature.Serialize(fb);
  (*m_collector)(fb);
}

void TestMwmBuilder::Finish()
{
  CHECK(m_collector, ("Finish() already was called."));
  m_collector.reset();

  feature::GenerateInfo info;
  info.m_targetDir = m_file.GetDirectory();
  info.m_tmpDir = m_file.GetDirectory();
  CHECK(GenerateFinalFeatures(info, m_file.GetCountryFile().GetNameWithoutExt(), m_type),
        ("Can't sort features."));

  string const path = m_file.GetPath(MapOptions::Map);
  CHECK(feature::BuildOffsetsTable(path), ("Can't build feature offsets table."));
  CHECK(indexer::BuildIndexFromDatFile(path, path),
        ("Can't build geometry index."));
  CHECK(indexer::BuildSearchIndexFromDatFile(path, true /* forceRebuild */),
        ("Can't build search index."));

  m_file.SyncWithDisk();
}
}  // namespace tests_support<commit_msg>[search, tests] Added removal of temprorary test files.<commit_after>#include "search/search_tests_support/test_mwm_builder.hpp"

#include "search/search_tests_support/test_feature.hpp"

#include "indexer/data_header.hpp"
#include "indexer/features_offsets_table.hpp"
#include "indexer/index_builder.hpp"
#include "indexer/search_index_builder.hpp"

#include "generator/feature_builder.hpp"
#include "generator/feature_generator.hpp"
#include "generator/feature_sorter.hpp"

#include "platform/local_country_file.hpp"

#include "coding/file_writer.hpp"

#include "base/logging.hpp"

#include "defines.hpp"

namespace search
{
namespace tests_support
{
TestMwmBuilder::TestMwmBuilder(platform::LocalCountryFile & file, feature::DataHeader::MapType type)
    : m_file(file),
      m_type(type),
      m_collector(
          make_unique<feature::FeaturesCollector>(m_file.GetPath(MapOptions::Map) + EXTENSION_TMP))
{
}

TestMwmBuilder::~TestMwmBuilder()
{
  if (m_collector)
    Finish();
  CHECK(!m_collector, ("Features weren't dumped on disk."));
  FileWriter::DeleteFileX(m_file.GetPath(MapOptions::Map) + EXTENSION_TMP);
}

void TestMwmBuilder::Add(TestFeature const & feature)
{
  CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
  FeatureBuilder1 fb;
  feature.Serialize(fb);
  (*m_collector)(fb);
}

void TestMwmBuilder::Finish()
{
  CHECK(m_collector, ("Finish() already was called."));
  m_collector.reset();

  feature::GenerateInfo info;
  info.m_targetDir = m_file.GetDirectory();
  info.m_tmpDir = m_file.GetDirectory();
  CHECK(GenerateFinalFeatures(info, m_file.GetCountryFile().GetNameWithoutExt(), m_type),
        ("Can't sort features."));

  string const path = m_file.GetPath(MapOptions::Map);
  CHECK(feature::BuildOffsetsTable(path), ("Can't build feature offsets table."));
  CHECK(indexer::BuildIndexFromDatFile(path, path),
        ("Can't build geometry index."));
  CHECK(indexer::BuildSearchIndexFromDatFile(path, true /* forceRebuild */),
        ("Can't build search index."));

  m_file.SyncWithDisk();
}
}  // namespace tests_support
{'fraction_non_alphanumeric': 0.13956941351150706, 'fraction_numerical': 0.0004949269982677555, 'mean_word_length': 5.945017182130584, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5519503', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1321, 'n_words': 234}