<commit_before>package com.ning;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Goal which runs lithium php unit tests and fails if they fail.
 *
 * @goal li3-test
 * @phase test
 */
public class Li3TestMojo extends AbstractMojo
{
    /**
     * Location of the file.
     *
     * @parameter expression="${basedir}"
     * @required
     */
    private File baseDir;

    private Log log;
    private Pattern passesPattern;
    private Pattern failsPattern;

    public Li3TestMojo()
    {
        log = getLog();
        passesPattern = Pattern.compile("(\\d+) / (\\d+) passes");
        failsPattern = Pattern.compile("(\\d+) fails and (\\d+) exceptions");
    }

    public void execute() throws MojoExecutionException, MojoFailureException
    {
        boolean failed = false;
        List<String> command = new ArrayList<String>();
        try {
            command.add(baseDir.getCanonicalPath() + "/libraries/lithium/console/li3");
        }
        catch (IOException e) {
            throw new MojoExecutionException("Couldn't get the canonical path of the basedir");
        }
        command.add("test");
        command.add("app/tests");
        ProcessBuilder builder = new ProcessBuilder(command);
        try {
            Process process = builder.start();
            BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
            BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
            String line;
            while ((line = input.readLine()) != null) {
                log.info(line);
                if(isFailure(line)){
                    failed = true;
                }
            }
            input.close();
            while ((line = error.readLine()) != null) {
                log.error(line);
                if(isFailure(line)){
                    failed = true;
                }
            }
            error.close();
            process.waitFor();
        }
        catch (IOException e) {
            throw new MojoExecutionException("Couldn't get process to start.");
        }
        catch (InterruptedException e) {<commit_msg>Errors should cause a failure.<commit_after>package com.ning;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Goal which runs lithium php unit tests and fails if they fail.
 *
 * @goal li3-test
 * @phase test
 */
public class Li3TestMojo extends AbstractMojo
{
    /**
     * Location of the file.
     *
     * @parameter expression="${basedir}"
     * @required
     */
    private File baseDir;

    private Log log;
    private Pattern passesPattern;
    private Pattern failsPattern;

    public Li3TestMojo()
    {
        log = getLog();
        passesPattern = Pattern.compile("(\\d+) / (\\d+) passes");
        failsPattern = Pattern.compile("(\\d+) fails and (\\d+) exceptions");
    }

    public void execute() throws MojoExecutionException, MojoFailureException
    {
        boolean failed = false;
        List<String> command = new ArrayList<String>();
        try {
            command.add(baseDir.getCanonicalPath() + "/libraries/lithium/console/li3");
        }
        catch (IOException e) {
            throw new MojoExecutionException("Couldn't get the canonical path of the basedir");
        }
        command.add("test");
        command.add("app/tests");
        ProcessBuilder builder = new ProcessBuilder(command);
        try {
            Process process = builder.start();
            BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
            BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
            String line;
            while ((line = input.readLine()) != null) {
                log.info(line);
                if(isFailure(line)){
                    failed = true;
                }
            }
            input.close();
            while ((line = error.readLine()) != null) {
                log.error(line);
                //If we see anything in the error log at all, fail.
                failed = true;
            }
            error.close();
            process.waitFor();
        }
        catch (IOException e) {
            throw new MojoExecutionException("Couldn't get process to start.");
        }
        catch (InterruptedException e) {
{'fraction_non_alphanumeric': 0.11212948517940717, 'fraction_numerical': 0.0015600624024961, 'mean_word_length': 2.209637046307885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7235456', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1340, 'n_words': 340}