<commit_before>package courgette.runtime;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static courgette.runtime.utils.SystemPropertyUtils.splitAndAddPropertyToList;

public class CourgetteFeatureRunner {
    private Map<String, List<String>> runnerArgs;
    private Boolean output;
    private static String classpath;
    private static List<String> systemProperties;

    public CourgetteFeatureRunner(Map<String, List<String>> runnerArgs, Boolean output) {
        this.runnerArgs = runnerArgs;
        this.output = output;
    }

    public int run() {
        Process process = null;
        try {
            final ProcessBuilder builder = new ProcessBuilder();

            if (output) {
                builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
            }
            builder.redirectErrorStream(Boolean.TRUE);

            final List<String> commands = new ArrayList<>();
            commands.add("java");
            splitAndAddPropertyToList(CourgetteSystemProperty.VM_OPTIONS, commands);
            commands.add("-cp");
            commands.add("\"" + classpath + "\"");
            systemProperties.forEach(commands::add);
            commands.add("cucumber.api.cli.Main");
            this.runnerArgs.entrySet().forEach(entry -> entry.getValue().forEach(commands::add));

            builder.command(commands);
            process = builder.start();
            process.waitFor();
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
        return process != null ? process.exitValue() : -1;
    }

    static {
        final StringBuffer classPathBuilder = new StringBuffer();

        final URL[] classPathUrls = ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs();
        Arrays.asList(classPathUrls).forEach(url -> classPathBuilder.append(String.format("%s%s", url.getPath().replace("file:", ""), File.pathSeparator)));

        classpath = classPathBuilder.toString();

        final List<String> systemPropertyList = new ArrayList<>();
        System.getProperties().keySet().forEach(property -> systemPropertyList.add(String.format("-D%s=%s", property, System.getProperty(property.toString()))));

        systemProperties = systemPropertyList;
    }
}<commit_msg>Removes conflicting cucumber options if provided by client.<commit_after>package courgette.runtime;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static courgette.runtime.utils.SystemPropertyUtils.splitAndAddPropertyToList;

public class CourgetteFeatureRunner {
    private Map<String, List<String>> runnerArgs;
    private Boolean output;
    private static String classpath;
    private static List<String> systemProperties;

    public CourgetteFeatureRunner(Map<String, List<String>> runnerArgs, Boolean output) {
        this.runnerArgs = runnerArgs;
        this.output = output;
    }

    public int run() {
        Process process = null;
        try {
            final ProcessBuilder builder = new ProcessBuilder();

            if (output) {
                builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
            }
            builder.redirectErrorStream(Boolean.TRUE);

            final List<String> commands = new ArrayList<>();
            commands.add("java");
            splitAndAddPropertyToList(CourgetteSystemProperty.VM_OPTIONS, commands);
            commands.add("-cp");
            commands.add("\"" + classpath + "\"");
            systemProperties.forEach(commands::add);
            commands.add("cucumber.api.cli.Main");
            this.runnerArgs.entrySet().forEach(entry -> entry.getValue().forEach(commands::add));

            builder.command(commands);
            process = builder.start();
            process.waitFor();
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
        return process != null ? process.exitValue() : -1;
    }

    static {
        final StringBuffer classPathBuilder = new StringBuffer();

        final URL[] classPathUrls = ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs();
        Arrays.asList(classPathUrls).forEach(url -> classPathBuilder.append(String.format("%s%s", url.getPath().replace("file:", ""), File.pathSeparator)));

        classpath = classPathBuilder.toString();

        final List<String> systemPropertyList = new ArrayList<>();
        System.getProperties().keySet().forEach(property -> systemPropertyList.add(String.format("-D%s=%s", property, System.getProperty(property.toString()))));
        systemPropertyList.removeIf(systemProperty -> systemProperty.startsWith("-Dcucumber.options"));

        systemProperties = systemPropertyList;
    }
}
{'fraction_non_alphanumeric': 0.12187375942834458, 'fraction_numerical': 0.0003969829297340214, 'mean_word_length': 3.0934199837530465, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, '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': '6887083', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1287, 'n_words': 253}