<commit_before>package nu.studer.teamcity.buildscan.agent

import jetbrains.buildServer.agent.AgentBuildFeature
import jetbrains.buildServer.agent.AgentCheckoutMode
import jetbrains.buildServer.agent.AgentRunningBuild
import jetbrains.buildServer.agent.BuildAgentConfiguration
import jetbrains.buildServer.agent.BuildInterruptReason
import jetbrains.buildServer.agent.BuildParametersMap
import jetbrains.buildServer.agent.BuildProgressLogger
import jetbrains.buildServer.agent.BuildRunnerContext
import jetbrains.buildServer.agent.BuildRunnerSettings
import jetbrains.buildServer.agent.ToolCannotBeFoundException
import jetbrains.buildServer.agent.VirtualContext
import jetbrains.buildServer.agentServer.AgentBuild
import jetbrains.buildServer.artifacts.ArtifactDependencyInfo
import jetbrains.buildServer.parameters.ValueResolver
import jetbrains.buildServer.util.Option
import jetbrains.buildServer.util.PasswordReplacer
import jetbrains.buildServer.vcs.VcsChangeInfo
import jetbrains.buildServer.vcs.VcsRoot
import jetbrains.buildServer.vcs.VcsRootEntry
import org.jetbrains.annotations.NotNull

class TestBuildRunnerContext implements BuildRunnerContext {

    private final String runType
    private final AgentRunningBuild agentRunningBuild
    private final BuildParametersMap buildParameters
    private final Map<String, String> configParameters
    private final Map<String, String> runnerParameters

    TestBuildRunnerContext(String runType, File agentTempDirectory, Map<String, String> configParameters, Map<String, String> runnerParameters) {
        this.runType = runType
        this.agentRunningBuild = new TestAgentRunningBuild(agentTempDirectory)
        this.buildParameters = new TestBuildParametersMap()
        this.configParameters = configParameters
        this.runnerParameters = runnerParameters
    }

    @Override
    String getRunType() {
        return runType
    }

    @Override
    AgentRunningBuild getBuild() {
        return agentRunningBuild
    }

    @Override
    BuildParametersMap getBuildParameters() {
        return buildParameters
    }

    @Override
    Map<String, String> getConfigParameters() {
        return configParameters
    }

    @Override
    Map<String, String> getRunnerParameters() {
        return runnerParameters
    }

    @Override
    void addSystemProperty(@NotNull String key, @NotNull String value) {
        buildParameters.systemProperties.put(key, value)
    }

    @Override
    void addEnvironmentVariable(@NotNull String key, @NotNull String value) {
        buildParameters.environmentVariables.put(key, value)
    }

    @Override
    void addConfigParameter(@NotNull String key, @NotNull String value) {
        configParameters.put(key, value)
    }

    @Override
    void addRunnerParameter(@NotNull String key, @NotNull String value) {
        runnerParameters.put(key, value)
    }

    @Override
    ValueResolver getParametersResolver() {
        return null
    }

    @Override
    String getToolPath(@NotNull String toolName) throws ToolCannotBeFoundException {
        return null
    }

    @Override
    boolean parametersHaveReferencesTo(@NotNull Collection<String> keys) {
        return false
    }

    @Override
    boolean isVirtualContext() {<commit_msg>Add support for passing tool paths to `TestBuildRunnerContext`<commit_after>package nu.studer.teamcity.buildscan.agent

import jetbrains.buildServer.agent.AgentBuildFeature
import jetbrains.buildServer.agent.AgentCheckoutMode
import jetbrains.buildServer.agent.AgentRunningBuild
import jetbrains.buildServer.agent.BuildAgentConfiguration
import jetbrains.buildServer.agent.BuildInterruptReason
import jetbrains.buildServer.agent.BuildParametersMap
import jetbrains.buildServer.agent.BuildProgressLogger
import jetbrains.buildServer.agent.BuildRunnerContext
import jetbrains.buildServer.agent.BuildRunnerSettings
import jetbrains.buildServer.agent.ToolCannotBeFoundException
import jetbrains.buildServer.agent.VirtualContext
import jetbrains.buildServer.agentServer.AgentBuild
import jetbrains.buildServer.artifacts.ArtifactDependencyInfo
import jetbrains.buildServer.parameters.ValueResolver
import jetbrains.buildServer.util.Option
import jetbrains.buildServer.util.PasswordReplacer
import jetbrains.buildServer.vcs.VcsChangeInfo
import jetbrains.buildServer.vcs.VcsRoot
import jetbrains.buildServer.vcs.VcsRootEntry
import org.jetbrains.annotations.NotNull

class TestBuildRunnerContext implements BuildRunnerContext {

    private final String runType
    private final AgentRunningBuild agentRunningBuild
    private final BuildParametersMap buildParameters
    private final Map<String, String> configParameters
    private final Map<String, String> runnerParameters
    private final Map<String, String> toolPaths

    TestBuildRunnerContext(String runType, File agentTempDirectory, Map<String, String> configParameters, Map<String, String> runnerParameters, Map<String, String> toolPaths = [:]) {
        this.runType = runType
        this.agentRunningBuild = new TestAgentRunningBuild(agentTempDirectory)
        this.buildParameters = new TestBuildParametersMap()
        this.configParameters = configParameters
        this.runnerParameters = runnerParameters
        this.toolPaths = toolPaths
    }

    @Override
    String getRunType() {
        return runType
    }

    @Override
    AgentRunningBuild getBuild() {
        return agentRunningBuild
    }

    @Override
    BuildParametersMap getBuildParameters() {
        return buildParameters
    }

    @Override
    Map<String, String> getConfigParameters() {
        return configParameters
    }

    @Override
    Map<String, String> getRunnerParameters() {
        return runnerParameters
    }

    @Override
    void addSystemProperty(@NotNull String key, @NotNull String value) {
        buildParameters.systemProperties.put(key, value)
    }

    @Override
    void addEnvironmentVariable(@NotNull String key, @NotNull String value) {
        buildParameters.environmentVariables.put(key, value)
    }

    @Override
    void addConfigParameter(@NotNull String key, @NotNull String value) {
        configParameters.put(key, value)
    }

    @Override
    void addRunnerParameter(@NotNull String key, @NotNull String value) {
        runnerParameters.put(key, value)
    }

    @Override
    String getToolPath(@NotNull String toolName) throws ToolCannotBeFoundException {
        if (!toolPaths.containsKey(toolName)) {
            throw new ToolCannotBeFoundException(toolName)
        }

        return toolPaths[toolName]
    }

    @Override
    ValueResolver getParametersResolver() {
        return null
    }

    @Override
    boolean parametersHaveReferencesTo(@NotNull Collection<String> keys) {
        return false
    }

    @Override
    boolean isVirtualContext() {
{'fraction_non_alphanumeric': 0.06403868698710434, 'fraction_numerical': 0.0, 'mean_word_length': 4.198019801980198, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5400066', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1668, 'n_words': 384}