<commit_before>#include <string.h> // strrchr, strncpy
#include <stdio.h> // stdout
#include <dummy/tap_reporter.h>

#include <engine/Common.h>

#include "TestTools.h"


void ChangeDirectoryToExecutableOrigin( const char* executablePath );

void TestLogHandler( LogLevel level, const char* line )
{
    switch(level)
    {
        case LOG_INFO:
            dummyLog("%s", line);
            break;

        case LOG_ERROR:
        case LOG_FATAL_ERROR:
            dummyLog("%s", line);
            break;

        default:
            assert(!"Unknown log level");
    }
}

void InitTests( int argc, char const * const * argv )
{
    ChangeDirectoryToExecutableOrigin(argv[0]);
    SetLogHandler(TestLogHandler);
    dummyInit(dummyGetTAPReporter(stdout));
    dummyAddInlineTests();
}

int RunTests()
{
    const int failedTests = dummyRunTests();
    SetLogHandler(DefaultLogHandler);
    //return failedTests; // TODO: prove marks failed tests as doubious, with this line
    return 0;
}

#if defined(WIN32)

#include <direct.h>
void ChangeDirectory( const char* directory )
{
    _chdir(directory);
}

#else

#include <unistd.h>
void ChangeDirectory( const char* directory )
{
    chdir(directory);
}

#endif

void ChangeDirectoryToExecutableOrigin( const char* executablePath )
{
#if defined(WIN32)
    const char seperator = '\\';
#else
    const char seperator = '/';
#endif
    const char* lastSeperator = strrchr(executablePath, seperator);
    if(lastSeperator)
    {
        char buffer[256];
        const int length = lastSeperator - executablePath;
        strncpy(buffer, executablePath, length);
        ChangeDirectory(buffer);
    }
    else
    {
        // Already in the directory of the executable.
    }
}<commit_msg>Fixed test tools<commit_after>#include <string.h> // strrchr, strncpy
#include <stdio.h> // stdout
#include <dummy/tap_reporter.h>

#include <engine/Common.h>

#include "TestTools.h"


void ChangeDirectoryToExecutableOrigin( const char* executablePath );

void TestLogHandler( LogLevel level, const char* line )
{
    switch(level)
    {
        case LOG_INFO:
            dummyLog("%s", line);
            break;

        case LOG_ERROR:
        case LOG_FATAL_ERROR:
            dummyLog("%s", line);
            break;

        default:
            assert(!"Unknown log level");
    }
}

void InitTests( int argc, char const * const * argv )
{
    ChangeDirectoryToExecutableOrigin(argv[0]);
    SetLogHandler(TestLogHandler);
    dummyInit(dummyGetTAPReporter(stdout));
    dummyAddInlineTests();
}

int RunTests()
{
    const int failedTests = dummyRunTests();
    SetLogHandler(DefaultLogHandler);
    //return failedTests; // TODO: prove marks failed tests as doubious, with this line
    return 0;
}

#if defined(WIN32)

#include <direct.h>
void ChangeDirectory( const char* directory )
{
    _chdir(directory);
}

#else

#include <unistd.h>
void ChangeDirectory( const char* directory )
{
    chdir(directory);
}

#endif

void ChangeDirectoryToExecutableOrigin( const char* executablePath )
{
#if defined(WIN32)
    const char seperator = '\\';
#else
    const char seperator = '/';
#endif
    const char* lastSeperator = strrchr(executablePath, seperator);
    if(lastSeperator)
    {
        char buffer[256];
        const int length = lastSeperator - executablePath;
        strncpy(buffer, executablePath, length);
        buffer[length] = '\0';
        ChangeDirectory(buffer);
    }
    else
    {
        // Already in the directory of the executable.
    }
}
{'fraction_non_alphanumeric': 0.11057418988061399, 'fraction_numerical': 0.005400795906765207, 'mean_word_length': 3.0125427594070695, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2457125', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1081, 'n_words': 274}