<commit_before>use strict;
use warnings;

# Hack to mark modules we provide here as already loaded
$INC{"Resmon/Module.pm"} = $0;
$INC{"Resmon/ExtComm.pm"} = $0;

package Resmon::Module;
use strict;
use warnings;

sub new {
    my ($class, $check_name, $config) = @_;
    my $self = {};
    $self->{config} = $config;
    $self->{check_name} = $check_name;
    bless ($self, $class);
    return $self;
}

1;

package Resmon::ExtComm;
use strict;
use warnings;

use base "Exporter";
our @EXPORT_OK = qw/cache_command run_command/;

sub cache_command($$) {
    my $command = shift;
    run_command($command);
}

sub run_command {
    my @cmd = @_;
    pipe(my ($r, $w));
    my $pid = fork();
    if($pid) {
        close($w);
        my @lines = <$r>;
        waitpid($pid, 0);
        return join("", @lines);
    } else {
        eval {
            open(STDOUT, ">&", $w);
            close($r);
            exec(@cmd);
        };
        exit();
    }
}

1;

package ResmonTest;

use lib '../../lib';

sub load_module {
    my $module = shift;
    my $check_name = shift;
    my $kvs = {@_};

    eval "use $module;";
    if ($@) {
        print "$@\n";
        exit 1;
    }
    my $obj = $module->new($check_name, $kvs);
    return $obj;
}
<commit_msg>Add the not implemented methods to the test suite (refs #12)<commit_after>use strict;
use warnings;

# Hack to mark modules we provide here as already loaded
$INC{"Resmon/Module.pm"} = $0;
$INC{"Resmon/ExtComm.pm"} = $0;

package Resmon::Module;
use strict;
use warnings;

sub new {
    my ($class, $check_name, $config) = @_;
    my $self = {};
    $self->{config} = $config;
    $self->{check_name} = $check_name;
    bless ($self, $class);
    return $self;
}


sub handler {
    die "Monitor not implemented. Perhaps this is a wilcard only module?\n";
}

sub wildcard_handler {
    die "Monitor not implemented. Perhaps this is a non-wildcard module?\n";
}

1;

1;

package Resmon::ExtComm;
use strict;
use warnings;

use base "Exporter";
our @EXPORT_OK = qw/cache_command run_command/;

sub cache_command($$) {
    my $command = shift;
    run_command($command);
}

sub run_command {
    my @cmd = @_;
    pipe(my ($r, $w));
    my $pid = fork();
    if($pid) {
        close($w);
        my @lines = <$r>;
        waitpid($pid, 0);
        return join("", @lines);
    } else {
        eval {
            open(STDOUT, ">&", $w);
            close($r);
            exec(@cmd);
        };
        exit();
    }
}

1;

package ResmonTest;

use lib '../../lib';

sub load_module {
    my $module = shift;
    my $check_name = shift;
    my $kvs = {@_};

    eval "use $module;";
    if ($@) {
        print "$@\n";
        exit 1;
    }
    my $obj = $module->new($check_name, $kvs);
    return $obj;
}

{'fraction_non_alphanumeric': 0.17203911626222385, 'fraction_numerical': 0.005432814197754437, 'mean_word_length': 2.368292682926829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6695943', 'n_tokens_mistral': 1011, 'n_tokens_neox': 994, 'n_words': 272}