<commit_before><?php

class CatchSignalsTest extends GracefulDeathBaseTest
{
    public function testCanTerminateWithSignalSentToSupervisorProcess()
    {
        $this->startProcessForFixture('stopOnSignal.php', function($process) {
            $this->stopProcessWithSignal($process, SIGTERM, function($stdout, $stderr) {
                $this->assertEquals('Bye Bye', $stdout);
            });
        });
    }

    protected function startProcessForFixture($fixture, $callback)
    {
        $descriptors = [
            0 => ['pipe', 'r'],
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $cwd = __DIR__ . '/../fixtures';
        $process = proc_open("php {$fixture}", $descriptors, $pipes, $cwd);
        stream_set_blocking($pipes[1], 0);
        stream_set_blocking($pipes[2], 0);
        usleep(100000);
        $callback([$process, $pipes]);
    }

    protected function stopProcessWithSignal($process, $signal, $callback)
    {
        list($process, $pipes) = $process;
        proc_terminate($process, $signal);
        usleep(250000); // Need to wait the signal has been dispatched to the supervisor process
        $stdout = stream_get_contents($pipes[1]);<commit_msg>Try to make CI pass<commit_after><?php

class CatchSignalsTest extends GracefulDeathBaseTest
{
    public function testCanTerminateWithSignalSentToSupervisorProcess()
    {
        $this->startProcessForFixture('stopOnSignal.php', function($process) {
            $this->stopProcessWithSignal($process, SIGTERM, function($stdout, $stderr) {
                $this->assertEquals('Bye Bye', $stdout);
            });
        });
    }

    protected function startProcessForFixture($fixture, $callback)
    {
        $descriptors = [
            0 => ['pipe', 'r'],
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $cwd = __DIR__ . '/../fixtures';
        $process = proc_open("php {$fixture}", $descriptors, $pipes, $cwd);
        stream_set_blocking($pipes[1], 0);
        stream_set_blocking($pipes[2], 0);
        usleep(100000);
        $callback([$process, $pipes]);
    }

    protected function stopProcessWithSignal($process, $signal, $callback)
    {
        list($process, $pipes) = $process;
        proc_terminate($process, $signal);
        usleep(500000); // Need to wait the signal has been dispatched to the supervisor process
        $stdout = stream_get_contents($pipes[1]);
{'fraction_non_alphanumeric': 0.14742014742014742, 'fraction_numerical': 0.01638001638001638, 'mean_word_length': 2.7071320182094083, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1070752', 'n_tokens_mistral': 744, 'n_tokens_neox': 706, 'n_words': 147}