<commit_before>
use strict;
use warnings;

use FindBin;
use Test::More;

my $scriptDir = "$FindBin::Bin";
my $binDir = "$scriptDir/../";
my $compiler = "$scriptDir/../compiler";
my $dummyFile = "TEST_RESULT_FILE";

# Test the examples in the examples directory
my $examplesDir = "$scriptDir/../examples/";

opendir(DIR, "$examplesDir");
my @examplesFiles = grep {
    $_ =~ /^.+\.mlo$/
} readdir(DIR);
closedir(DIR);

unless (-x $compiler) {
    chdir($binDir);
    unless (system("make") == 0 && -x $compiler) {
        die "Failed to 'make' non-existing $compiler\n";
    }
    chdir($scriptDir);
}

foreach my $file (@examplesFiles) {
    ok(
        system("$compiler", "$examplesDir$file", "--o", $dummyFile) == 0,
        "Compiling: $file"
    );
}

if (-e $dummyFile) {
    unlink $dummyFile;
}

done_testing;
<commit_msg>Make it possible to run the regression test from any directory<commit_after>
use strict;
use warnings;

use FindBin;
use Test::More;

my $scriptDir = "$FindBin::Bin";
my $binDir = "$scriptDir/../";
my $compiler = "$scriptDir/../compiler";
my $dummyFile = "TEST_RESULT_FILE";

# Test the examples in the examples directory
my $examplesDir = "$scriptDir/../examples/";

opendir(DIR, "$examplesDir");
my @examplesFiles = grep {
    $_ =~ /^.+\.mlo$/
} readdir(DIR);
closedir(DIR);

chdir($binDir);

unless (-x $compiler) {
    unless (system("make") == 0 && -x $compiler) {
        die "Failed to 'make' non-existing $compiler\n";
    }
}

foreach my $file (@examplesFiles) {
    ok(
        system("$compiler", "$examplesDir$file", "--o", $dummyFile) == 0,
        "Compiling: $file"
    );
}

if (-e $dummyFile) {
    unlink $dummyFile;
}

chdir($scriptDir);

done_testing;

{'fraction_non_alphanumeric': 0.18790369935408102, 'fraction_numerical': 0.002348796241926013, 'mean_word_length': 3.544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6156942', 'n_tokens_mistral': 618, 'n_tokens_neox': 590, 'n_words': 156}