<commit_before>/*
 * SETTE - Symbolic Execution based Test Tool Evaluator
 *
 * SETTE is a tool to help the evaluation and comparison of symbolic execution based test input 
 * generator tools.
 *
 * Budapest University of Technology and Economics (BME)
 *
 * Authors: <NAME> <<EMAIL>>, <NAME> <<EMAIL>>
 *
 * Copyright 2014-2016
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the 
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 * express or implied. See the License for the specific language governing permissions and 
 * limitations under the License.
 */
// NOTE revise this file
package hu.bme.mit.sette.application;

import static com.google.common.base.Preconditions.checkArgument;
import static java.util.stream.Collectors.joining;

import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Path;
import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;

import hu.bme.mit.sette.core.configuration.SetteConfiguration;
import hu.bme.mit.sette.core.configuration.SetteToolConfiguration;
import hu.bme.mit.sette.core.model.snippet.SnippetProject;
import hu.bme.mit.sette.core.tasks.CsvBatchGenerator;
import hu.bme.mit.sette.core.tasks.CsvGenerator;
import hu.bme.mit.sette.core.tasks.TestSuiteGenerator;
import hu.bme.mit.sette.core.tasks.TestSuiteRunner;
import hu.bme.mit.sette.core.tool.Tool;
import hu.bme.mit.sette.snippetbrowser.SnippetBrowser;

public final class SetteApplication {
    private final Logger LOG = LoggerFactory.getLogger(getClass());

    private final BufferedReader input;
    private final PrintStream output;
    private final PrintStream errorOutput;
    private final Path configurationFile;

    public SetteApplication(BufferedReader input, PrintStream output, PrintStream errorOutput,
            Path configurationFile) {
        this.input = input;
        this.output = output;
        this.errorOutput = errorOutput;
        this.configurationFile = configurationFile;
    }

    public void execute(String... args) {
        try {
            //
            // Parse configuration
            //
            SetteConfiguration configuration = SetteConfiguration.parse(configurationFile);

            //
            // Determine what to do in this execution
            //

            // Parse arguments
            ArgumentParser argParser = new ArgumentParser(configuration, errorOutput);
            if (!argParser.parse(args)) {
                LOG.debug("Exiting (invalid cmd-line arguments or --help was specified");
                return;
            }

            Path snippetProjectDir;
            if (argParser.getSnippetProjectDir() != null) {
                snippetProjectDir = configuration.getBaseDir()
                        .resolve(argParser.getSnippetProjectDir());
            } else {
                snippetProjectDir = null;
            }
            ApplicationTask applicationTask = argParser.getApplicationTask();
            SetteToolConfiguration toolConfiguration = argParser.getToolConfiguration();
            String runnerProjectTag = argParser.getRunnerProjectTag();

            int runnerTimeoutInMs = argParser.getRunnerTimeoutInMs();
            BackupPolicy backupPolicy = argParser.getBackupPolicy();

            // Determine the snippet project if needed
            if (snippetProjectDir == null) {
                snippetProjectDir = selectSnippetProjectDir(configuration.getSnippetProjectDirs());
            }

            // Determine the task if needed (and exit if specified)
            if (applicationTask == null) {
                applicationTask = selectApplicationTask();
            }

            if (applicationTask == ApplicationTask.EXIT) {
                LOG.debug("Exiting for user request");
                return;
            }

            // Determine the tool if needed
            Tool tool = null;
            if (applicationTask.requiresTool()) {
                if (toolConfiguration == null) {
                    toolConfiguration = selectToolConfiguration(
                            configuration.getToolConfigurations());
                }
                tool = Tool.create(toolConfiguration);
            } else {
                if (toolConfiguration != null) {
                    String msg = String.format("The tool is specified (%s) but for the %s task "
                            + "it is not required, thus it will not affect the current execution",
                            toolConfiguration.getName(), applicationTask);
                    output.println(msg);
                    LOG.debug(msg);
                    toolConfiguration = null;
                }
            }

            // Determine the runner project tag if needed
            if (applicationTask.requiresRunnerProjectTag()) {
                if (runnerProjectTag == null) {
                    output.print("Enter a runner project tag: ");
                    runnerProjectTag = readLineOrExitIfEOF().trim();
                }
            } else {
                if (runnerProjectTag != null) {
                    String msg = String.format("The runner project tag is specified (%s) but for "
                            + "the %s task it is not required, thus it will not affect the "
                            + "current execution", runnerProjectTag);
                    output.println(msg);
                    LOG.debug(msg);
                    runnerProjectTag = null;
                }
            }

            // Print settings
            output.println("Snippet project: " + snippetProjectDir);
            output.println("Task: " + applicationTask);
            output.println("Tool: " + tool);
            output.println("Runner project tag: " + runnerProjectTag);
            output.println("Snippet selector: " + argParser.getSnippetSelector());
            output.println(
                    String.format("Runner timeout: %d ms", runnerTimeoutInMs));
            output.println("Backup policy: " + backupPolicy);

            //
            // Execute the specified task
            //
            SnippetProject snippetProject = SnippetProject.parse(snippetProjectDir);
            ExecutionContext context = new ExecutionContext(input, output, errorOutput,
                    snippetProject, tool, runnerProjectTag, runnerTimeoutInMs,
                    argParser.getSnippetSelector(), backupPolicy, configuration.getOutputDir());
<commit_msg>Added missing applicationTask to the error message in String.format<commit_after>/*
 * SETTE - Symbolic Execution based Test Tool Evaluator
 *
 * SETTE is a tool to help the evaluation and comparison of symbolic execution based test input 
 * generator tools.
 *
 * Budapest University of Technology and Economics (BME)
 *
 * Authors: <NAME> <<EMAIL>>, <NAME> <<EMAIL>>
 *
 * Copyright 2014-2016
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the 
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 * express or implied. See the License for the specific language governing permissions and 
 * limitations under the License.
 */
// NOTE revise this file
package hu.bme.mit.sette.application;

import static com.google.common.base.Preconditions.checkArgument;
import static java.util.stream.Collectors.joining;

import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Path;
import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;

import hu.bme.mit.sette.core.configuration.SetteConfiguration;
import hu.bme.mit.sette.core.configuration.SetteToolConfiguration;
import hu.bme.mit.sette.core.model.snippet.SnippetProject;
import hu.bme.mit.sette.core.tasks.CsvBatchGenerator;
import hu.bme.mit.sette.core.tasks.CsvGenerator;
import hu.bme.mit.sette.core.tasks.TestSuiteGenerator;
import hu.bme.mit.sette.core.tasks.TestSuiteRunner;
import hu.bme.mit.sette.core.tool.Tool;
import hu.bme.mit.sette.snippetbrowser.SnippetBrowser;

public final class SetteApplication {
    private final Logger LOG = LoggerFactory.getLogger(getClass());

    private final BufferedReader input;
    private final PrintStream output;
    private final PrintStream errorOutput;
    private final Path configurationFile;

    public SetteApplication(BufferedReader input, PrintStream output, PrintStream errorOutput,
            Path configurationFile) {
        this.input = input;
        this.output = output;
        this.errorOutput = errorOutput;
        this.configurationFile = configurationFile;
    }

    public void execute(String... args) {
        try {
            //
            // Parse configuration
            //
            SetteConfiguration configuration = SetteConfiguration.parse(configurationFile);

            //
            // Determine what to do in this execution
            //

            // Parse arguments
            ArgumentParser argParser = new ArgumentParser(configuration, errorOutput);
            if (!argParser.parse(args)) {
                LOG.debug("Exiting (invalid cmd-line arguments or --help was specified");
                return;
            }

            Path snippetProjectDir;
            if (argParser.getSnippetProjectDir() != null) {
                snippetProjectDir = configuration.getBaseDir()
                        .resolve(argParser.getSnippetProjectDir());
            } else {
                snippetProjectDir = null;
            }
            ApplicationTask applicationTask = argParser.getApplicationTask();
            SetteToolConfiguration toolConfiguration = argParser.getToolConfiguration();
            String runnerProjectTag = argParser.getRunnerProjectTag();

            int runnerTimeoutInMs = argParser.getRunnerTimeoutInMs();
            BackupPolicy backupPolicy = argParser.getBackupPolicy();

            // Determine the snippet project if needed
            if (snippetProjectDir == null) {
                snippetProjectDir = selectSnippetProjectDir(configuration.getSnippetProjectDirs());
            }

            // Determine the task if needed (and exit if specified)
            if (applicationTask == null) {
                applicationTask = selectApplicationTask();
            }

            if (applicationTask == ApplicationTask.EXIT) {
                LOG.debug("Exiting for user request");
                return;
            }

            // Determine the tool if needed
            Tool tool = null;
            if (applicationTask.requiresTool()) {
                if (toolConfiguration == null) {
                    toolConfiguration = selectToolConfiguration(
                            configuration.getToolConfigurations());
                }
                tool = Tool.create(toolConfiguration);
            } else {
                if (toolConfiguration != null) {
                    String msg = String.format("The tool is specified (%s) but for the %s task "
                            + "it is not required, thus it will not affect the current execution",
                            toolConfiguration.getName(), applicationTask);
                    output.println(msg);
                    LOG.debug(msg);
                    toolConfiguration = null;
                }
            }

            // Determine the runner project tag if needed
            if (applicationTask.requiresRunnerProjectTag()) {
                if (runnerProjectTag == null) {
                    output.print("Enter a runner project tag: ");
                    runnerProjectTag = readLineOrExitIfEOF().trim();
                }
            } else {
                if (runnerProjectTag != null) {
                    String msg = String.format("The runner project tag is specified (%s) but for "
                            + "the %s task it is not required, thus it will not affect the "
                            + "current execution", runnerProjectTag, applicationTask);
                    output.println(msg);
                    LOG.debug(msg);
                    runnerProjectTag = null;
                }
            }

            // Print settings
            output.println("Snippet project: " + snippetProjectDir);
            output.println("Task: " + applicationTask);
            output.println("Tool: " + tool);
            output.println("Runner project tag: " + runnerProjectTag);
            output.println("Snippet selector: " + argParser.getSnippetSelector());
            output.println(
                    String.format("Runner timeout: %d ms", runnerTimeoutInMs));
            output.println("Backup policy: " + backupPolicy);

            //
            // Execute the specified task
            //
            SnippetProject snippetProject = SnippetProject.parse(snippetProjectDir);
            ExecutionContext context = new ExecutionContext(input, output, errorOutput,
                    snippetProject, tool, runnerProjectTag, runnerTimeoutInMs,
                    argParser.getSnippetSelector(), backupPolicy, configuration.getOutputDir());

{'fraction_non_alphanumeric': 0.08477146364358437, 'fraction_numerical': 0.002021806628637447, 'mean_word_length': 2.118666966899347, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2652802', 'n_tokens_mistral': 3383, 'n_tokens_neox': 3224, 'n_words': 919}