<commit_before>#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use File::Temp qw(tempdir);

use tool::Util;


my @files = glob 't/run/*.jsx';

plan tests => 4 * scalar @files;

{
    local $ENV{JSX_HOME} = tempdir(".jsx.mode-parse-XXXXXXXX");

    require tool::RunCompilationServer;
    require "tool/jsx.pl"; # App::jsx

    my $port = do {
        open my $fh, "<", "$ENV{JSX_HOME}/port" or die $!;
        <$fh>;
    };

    foreach my $file(@files) {
        local $TODO = "todo" if $file =~ / \.todo\. /xms;

        my $res = App::jsx::request($port, "--mode", "parse", $file);

        ok !$res->{invalid_response}, "--mode parse $file";
        is $res->{statusCode}, 0, "statusCode";
        is $res->{stderr}, "", "stderr";
        ok $res->{stdout}, "stdout"
    }
}
<commit_msg>remove temp dirs used in tests<commit_after>#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use File::Temp qw(tempdir);

use tool::Util;


my @files = glob 't/run/*.jsx';

plan tests => 4 * scalar @files;

{
    local $ENV{JSX_HOME} = tempdir(".jsx.mode-parse-XXXXXXXX", CLEANUP => 1);

    require tool::RunCompilationServer;
    require "tool/jsx.pl"; # App::jsx

    my $port = do {
        open my $fh, "<", "$ENV{JSX_HOME}/port" or die $!;
        <$fh>;
    };

    foreach my $file(@files) {
        local $TODO = "todo" if $file =~ / \.todo\. /xms;

        my $res = App::jsx::request($port, "--mode", "parse", $file);

        ok !$res->{invalid_response}, "--mode parse $file";
        is $res->{statusCode}, 0, "statusCode";
        is $res->{stderr}, "", "stderr";
        ok $res->{stdout}, "stdout"
    }
}

{'fraction_non_alphanumeric': 0.20759338640538885, 'fraction_numerical': 0.003061849357011635, 'mean_word_length': 2.6719101123595506, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6915995', 'n_tokens_mistral': 628, 'n_tokens_neox': 600, 'n_words': 147}