Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Changed dotnet executable args order (#19)
Browse files Browse the repository at this point in the history
## Description

Fixed small bug where dotnet executable extra args were positioned before the solution path, when they should be after it. 

## Changes
* ![FIX] argument order for dotnet executable
  • Loading branch information
Joaquimmnetto authored Jan 11, 2022
1 parent 7417bab commit eccf330
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

plugins {
id 'net.wooga.plugins' version '2.2.1' //needs git repository with filled HEAD (at least one commit)
id 'net.wooga.plugins' version '2.2.3'
}

group 'net.wooga.gradle'
Expand Down Expand Up @@ -52,7 +52,7 @@ dependencies {
api 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.2.0'
implementation 'gradle.plugin.net.wooga.gradle:atlas-github:2.+'
testImplementation 'com.wooga.spock.extensions:spock-github-extension:0.2.0'
testImplementation 'org.ajoberstar.grgit:grgit-core:4.1.0'
testImplementation 'org.ajoberstar.grgit:grgit-core:4.+'
}

configurations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {
}

@Unroll
def "Builds a C# solution with #tool #subtool command"() {
def "Builds a C# solution with dotnet #subtool #extraArgs command"() {
given: "a msbuild executable"
def fakeBuildExec = argReflectingFakeExecutable(tool, 0)
def fakeBuildExec = argReflectingFakeExecutable("dotnet", 0)
and: "build file with configured task"
buildFile << """
project.tasks.create("solutionBuild", ${BuildSolution.name}) {
${tool}Executable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)}
dotnetExecutable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)}
solution = ${wrapValueBasedOnType(solutionPath, File)}
environment = ${wrapValueBasedOnType(environment, Map)}
extraArgs = ${wrapValueBasedOnType(extraArgs, List)}
Expand All @@ -36,15 +36,41 @@ class BuildSolutionTaskIntegrationSpec extends PluginIntegrationSpec {

then:
def buildResult = executionResults(fakeBuildExec, result)
buildResult.args == subtool + extraArgs + [Paths.get(projectDir.absolutePath, solutionPath).toString()]
buildResult.args == subtool + [Paths.get(projectDir.absolutePath, solutionPath).toString()] + extraArgs
buildResult.envs.entrySet().containsAll(environment.entrySet())

where:
tool | solutionPath | subtool | environment | extraArgs
"msBuild" | "solution.sln" | [] | ["a": "b"] | []
"msBuild" | "solution.sln" | [] | [:] | ["-arg", "/arg:value"]
"dotnet" | "dir/solution.sln" | ["build"] | [:] | []
"dotnet" | "dir/solution.sln" | ["build"] | ["b": "c"] | ["-arg", "/arg:value"]
solutionPath | subtool | environment | extraArgs
"dir/solution.sln" | ["build"] | [:] | []
"dir/solution.sln" | ["build"] | ["b": "c"] | ["-arg", "/arg:value"]
}


@Unroll
def "Builds a C# solution with msbuild #extraArgs command"() {
given: "a msbuild executable"
def fakeBuildExec = argReflectingFakeExecutable("msBuild", 0)
and: "build file with configured task"
buildFile << """
project.tasks.create("solutionBuild", ${BuildSolution.name}) {
msBuildExecutable = ${wrapValueBasedOnType(fakeBuildExec.absolutePath, File)}
solution = ${wrapValueBasedOnType(solutionPath, File)}
environment = ${wrapValueBasedOnType(environment, Map)}
extraArgs = ${wrapValueBasedOnType(extraArgs, List)}
}
"""
when:
def result = runTasksSuccessfully("solutionBuild")

then:
def buildResult = executionResults(fakeBuildExec, result)
buildResult.args == extraArgs + [Paths.get(projectDir.absolutePath, solutionPath).toString()]
buildResult.envs.entrySet().containsAll(environment.entrySet())

where:
solutionPath | environment | extraArgs
"solution.sln" | ["a": "b"] | []
"solution.sln" | [:] | ["-arg", "/arg:value"]
}

@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class DotNet implements SolutionBuildTool {
execSpec.executable = executable.absolutePath
execSpec.environment(environment)
execSpec.args("build")
execSpec.args(*extraArgs)
execSpec.args(solution.absolutePath)
execSpec.args(*extraArgs)
}.throwsOnFailure()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DotNetSpec extends Specification {

then:
shell.lastExecSpec.executable == executable.absolutePath
shell.lastExecSpec.args == ["build"] + extraArgs + [solution.absolutePath]
shell.lastExecSpec.args == ["build"] + [solution.absolutePath] + extraArgs
shell.lastExecSpec.environment.entrySet().containsAll(environment.entrySet())

where:
Expand Down

0 comments on commit eccf330

Please sign in to comment.