<commit_before>package com.zenika.plugins.varnishtest;

import java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

@Mojo(name = "run", defaultPhase = LifecyclePhase.INTEGRATION_TEST)
public class RunMojo extends AbstractMojo {
	
	@Parameter(defaultValue = "${project.build.directory}/varnishtest")
	private File outputDirectory;
	
	public void execute() throws MojoExecutionException {
		outputDirectory.mkdirs();
	}
}
<commit_msg>initial implementation of the run mojo<commit_after>package com.zenika.plugins.varnishtest;

import java.io.File;
import java.util.List;

import org.apache.commons.exec.CommandLine;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;

@Mojo(name = "run", defaultPhase = LifecyclePhase.INTEGRATION_TEST)
public class RunMojo extends AbstractMojo {

	private static final String[] EMPTY_STRING_ARRAY = new String[] {};
	private static final String[] DEFAULT_INCLUDE = new String[] {"src/test/varnish/**.vtc"};
	
	@Component
	private MavenProject project;
	
	@Parameter(defaultValue = "${project.build.directory}/varnishtest")
	private File outputDirectory;
    
	@Parameter
	private List<String> includes;
	
    @Parameter
    protected List<String> excludes;
	
	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		
		outputDirectory.mkdirs();
		
		CommandLine commandLine = new CommandLine("varnishtest");
		commandLine.addArgument("-Dvarnishd=varnishd", false);
		commandLine.addArgument("-Dproject.basedir=" + getBasedir(), true);
		
		for (String testCase : getTestCases()) {
			VarnishtestRunner runner = new VarnishtestRunner(commandLine);
			runner.runTestCase(this, new File(getBasedir(), testCase), 20);
		}
		
	}
	
	private String[] getTestCases() {
		DirectoryScanner scanner = new DirectoryScanner();
		scanner.setBasedir(getBasedir());
		scanner.setIncludes(getIncludes());
		scanner.setExcludes(getExcludes());
		scanner.scan();
		
		String[] testCases = scanner.getIncludedFiles();
		return testCases != null ? testCases : EMPTY_STRING_ARRAY;
	}

	private File getBasedir() {
		return project.getBasedir();
	}

	private String[] getExcludes() {
		if (excludes == null || excludes.isEmpty()) {
			return EMPTY_STRING_ARRAY;
		}
		return excludes.toArray(EMPTY_STRING_ARRAY);
	}

	private String[] getIncludes() {
		if (includes == null || includes.isEmpty()) {
			return DEFAULT_INCLUDE;
		}
		return includes.toArray(EMPTY_STRING_ARRAY);
	}
}

{'fraction_non_alphanumeric': 0.11433224755700326, 'fraction_numerical': 0.0006514657980456026, 'mean_word_length': 5.604301075268817, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2765852', 'n_tokens_mistral': 1018, 'n_tokens_neox': 922, 'n_words': 182}