<commit_before>#include <QDebug>
#include <QFileInfo>
#include <QRegularExpression>

#include <cpptools/cppmodelmanager.h>
#include <cpptools/searchsymbols.h>
#include <cplusplus/DependencyTable.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>

#include "TestProject.h"
#include "CustomRunConfiguration.h"

using namespace QtcGtest::Internal;

using namespace Core;
using namespace ProjectExplorer;
using namespace CppTools;
using namespace CPlusPlus;

namespace
{
  const QString gtestInclude = QLatin1String ("gtest.h");
  const QString gtestFilter = QLatin1String ("--gtest_filter=%1");
  const QString gtestFilterSeparator = QLatin1String (":");
  const QRegularExpression testPattern (QLatin1String ("(?:TEST|TEST_F)\\s*\\((\\w+),\\s*\\w+\\)"));


  QString shortenFileName (const QString& file)
  {
    QFileInfo f (file);
    QString newName = f.absolutePath () + QLatin1Char ('/') + f.baseName ();
    return newName;
  }
}

TestProject::TestProject(QObject *parent) :
  QObject(parent)
{
}

void TestProject::checkProject()
{
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration != NULL)
  {
    runTests (configuration);
  }
}

void TestProject::runTests(CustomRunConfiguration *configuration) const
{
  Q_ASSERT (configuration != NULL);
  ProjectExplorerPlugin* plugin = ProjectExplorerPlugin::instance ();
  plugin->runRunConfiguration (configuration, NormalRunMode, true);
  configuration->deleteLater ();
}

void TestProject::checkChanged()
{
  if (changedFiles_.isEmpty ())
  {
    return;
  }
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration != NULL)
  {
    runTestsForFiles (changedFiles_, configuration);
  }
}

void TestProject::checkCurrent()
{
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration == NULL)
  {
    return;
  }

  IDocument* document = EditorManager::currentDocument ();
  QString file = document->filePath ();
  QStringList files = project->files (Project::ExcludeGeneratedFiles);
  if (!files.contains (file))
  {
    return;
  }

  runTestsForFiles (QStringList () << file, configuration);
}

void TestProject::runTestsForFiles(const QStringList &files, CustomRunConfiguration *configuration) const
{<commit_msg>Clear changed files after run<commit_after>#include <QDebug>
#include <QFileInfo>
#include <QRegularExpression>

#include <cpptools/cppmodelmanager.h>
#include <cpptools/searchsymbols.h>
#include <cplusplus/DependencyTable.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>

#include "TestProject.h"
#include "CustomRunConfiguration.h"

using namespace QtcGtest::Internal;

using namespace Core;
using namespace ProjectExplorer;
using namespace CppTools;
using namespace CPlusPlus;

namespace
{
  const QString gtestInclude = QLatin1String ("gtest.h");
  const QString gtestFilter = QLatin1String ("--gtest_filter=%1");
  const QString gtestFilterSeparator = QLatin1String (":");
  const QRegularExpression testPattern (QLatin1String ("(?:TEST|TEST_F)\\s*\\((\\w+),\\s*\\w+\\)"));


  QString shortenFileName (const QString& file)
  {
    QFileInfo f (file);
    QString newName = f.absolutePath () + QLatin1Char ('/') + f.baseName ();
    return newName;
  }
}

TestProject::TestProject(QObject *parent) :
  QObject(parent)
{
}

void TestProject::checkProject()
{
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration != NULL)
  {
    runTests (configuration);
  }
}

void TestProject::runTests(CustomRunConfiguration *configuration) const
{
  Q_ASSERT (configuration != NULL);
  ProjectExplorerPlugin* plugin = ProjectExplorerPlugin::instance ();
  plugin->runRunConfiguration (configuration, NormalRunMode, true);
  configuration->deleteLater ();
}

void TestProject::checkChanged()
{
  if (changedFiles_.isEmpty ())
  {
    return;
  }
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration != NULL)
  {
    runTestsForFiles (changedFiles_, configuration);
    changedFiles_.clear ();
  }
}

void TestProject::checkCurrent()
{
  Project* project = SessionManager::startupProject ();
  CustomRunConfiguration* configuration = parse (project);
  if (configuration == NULL)
  {
    return;
  }

  IDocument* document = EditorManager::currentDocument ();
  QString file = document->filePath ();
  QStringList files = project->files (Project::ExcludeGeneratedFiles);
  if (!files.contains (file))
  {
    return;
  }

  runTestsForFiles (QStringList () << file, configuration);
}

void TestProject::runTestsForFiles(const QStringList &files, CustomRunConfiguration *configuration) const
{
{'fraction_non_alphanumeric': 0.12700320512820512, 'fraction_numerical': 0.002403846153846154, 'mean_word_length': 5.501302083333333, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 29, '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': '6395398', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1455, 'n_words': 325}