<commit_before><?php

namespace Korobi\WebBundle\Deployment\Processor;

use Korobi\WebBundle\Deployment\DeploymentInfo;
use Korobi\WebBundle\Deployment\DeploymentStatus;
use Korobi\WebBundle\Deployment\TestOutputParser;

/**
 * Runs the tests.
 *
 * @package Korobi\WebBundle\Deployment\Processor
 */
class RunTests extends BaseProcessor implements DeploymentProcessorInterface {

    /**
     * Does the actual test work.
     * @param DeploymentInfo $deploymentInfo
     * @return string
     */
    public function handle(DeploymentInfo $deploymentInfo) {
        chdir($deploymentInfo->getRootPath() . DIRECTORY_SEPARATOR . 'app');
        $execOutput = [];
        $testOutput = exec('phpunit', $execOutput);
        $parsed = (new TestOutputParser())->parseLine($testOutput);
        $message = $this->akio->startMessage()->insertGreen()->insertText($parsed['passed'] . " tests passed.");

        if ($parsed['incomplete'] > 0) {
            $message = $message->insertYellow(" " . $parsed['incomplete'] . " skipped/risky tests.");
        }

        if ($parsed['failures'] > 0) {
            $this->logger->debug("Tests failed!", [implode("\n", $execOutput)], true);
            $message = $message->insertRed(" " . $parsed['failed'] . " failed.");
            $deploymentInfo->addStatus(DeploymentStatus::$TESTS_FAILED);
        }

        $this->akio->sendMessage($message);
        $this->akio->sendMessage($this->akio->startMessage()->insertText(json_encode($parsed)));
        $deploymentInfo->getRevision()->setTestsOutput(implode("\n", $execOutput));<commit_msg>More diagnostics<commit_after><?php

namespace Korobi\WebBundle\Deployment\Processor;

use Korobi\WebBundle\Deployment\DeploymentInfo;
use Korobi\WebBundle\Deployment\DeploymentStatus;
use Korobi\WebBundle\Deployment\TestOutputParser;

/**
 * Runs the tests.
 *
 * @package Korobi\WebBundle\Deployment\Processor
 */
class RunTests extends BaseProcessor implements DeploymentProcessorInterface {

    /**
     * Does the actual test work.
     * @param DeploymentInfo $deploymentInfo
     * @return string
     */
    public function handle(DeploymentInfo $deploymentInfo) {
        chdir($deploymentInfo->getRootPath() . DIRECTORY_SEPARATOR . 'app');
        $execOutput = [];
        $testOutput = exec('phpunit', $execOutput);
        $parsed = (new TestOutputParser())->parseLine($testOutput);
        $this->akio->sendMessage($this->akio->startMessage()->insertText("Parsing line \"$testOutput\" => " . json_encode($parsed)));

        $message = $this->akio->startMessage()->insertGreen()->insertText($parsed['passed'] . " tests passed.");

        if ($parsed['incomplete'] > 0) {
            $message = $message->insertYellow(" " . $parsed['incomplete'] . " skipped/risky tests.");
        }

        if ($parsed['failures'] > 0) {
            $this->logger->debug("Tests failed!", [implode("\n", $execOutput)], true);
            $message = $message->insertRed(" " . $parsed['failed'] . " failed.");
            $deploymentInfo->addStatus(DeploymentStatus::$TESTS_FAILED);
        }

        $this->akio->sendMessage($message);

        $deploymentInfo->getRevision()->setTestsOutput(implode("\n", $execOutput));
{'fraction_non_alphanumeric': 0.16322701688555347, 'fraction_numerical': 0.0012507817385866166, 'mean_word_length': 3.5375886524822695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '3830121', 'n_tokens_mistral': 922, 'n_tokens_neox': 914, 'n_words': 149}