You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please find enclosed a demo project demonstrating an incorrect forwarding/usage of the PATH environment variable by the Gradle Runner/TestKit.
Project: gradle-exec.zip
Description
The single test class in the project performs the following actions:
Create 2 identical shell scripts with the same file name mycommand, that echoes their absolute path and the content of the PATH environment variable. Both scripts are created in 2 temporary directories whose name starts with bin1- prefix, respectively bin2- prefix.
Create a build.gradle file with a myTask task based on the Exec type, that simply executes the mycommand command, relying on the PATH environment variable to locate it.
Execute test shouldExecCommandInBin1: prepend the PATH environment variable with bin1-... directory, and provide this variable to the Gradle Runner. The expected result here is command bin1-.../ mycommand is executed, which is OK.
Execute test shouldExecCommandInBin2: prepend the PATH environment variable with bin2-... directory, and provide this variable to the Gradle Runner. The expected result here is command bin2-.../mycommand is executed, which is KO. Indeed, even if the content of the PATH environment variable seems relevant once in the command shell script, the Gradle Runner executes the bin1-.../mycommand command.
Below you will find the output of a gradlew test command:
Maybe I made a mistake, but actually I don't understand why such result. It is also strange for me because the PATH environment variable is relevant once in the shell script.
Thanks in advance for your help!
BR,
Vincent
The text was updated successfully, but these errors were encountered:
v1nc3n4
changed the title
Bad command resolution with Exec task, PATH environment variable, and TestKit
Bad command execution with Exec task, overwritten PATH environment variable, and TestKit
Apr 30, 2020
Hello,
Please find enclosed a demo project demonstrating an incorrect forwarding/usage of the
PATH
environment variable by the Gradle Runner/TestKit.Project: gradle-exec.zip
Environment
O/S: Ubuntu 18.04.4 LTS
JDK: OpenJDK 1.8.0_242 64 bits
Gradle: 6.3
Description
The single test class in the project performs the following actions:
mycommand
, that echoes their absolute path and the content of thePATH
environment variable. Both scripts are created in 2 temporary directories whose name starts withbin1-
prefix, respectivelybin2-
prefix.build.gradle
file with amyTask
task based on theExec
type, that simply executes themycommand
command, relying on thePATH
environment variable to locate it.shouldExecCommandInBin1
: prepend thePATH
environment variable withbin1-...
directory, and provide this variable to the Gradle Runner. The expected result here is commandbin1-.../ mycommand
is executed, which is OK.shouldExecCommandInBin2
: prepend thePATH
environment variable withbin2-...
directory, and provide this variable to the Gradle Runner. The expected result here is commandbin2-.../mycommand
is executed, which is KO. Indeed, even if the content of thePATH
environment variable seems relevant once in the command shell script, the Gradle Runner executes thebin1-.../mycommand
command.Below you will find the output of a
gradlew test
command:Maybe I made a mistake, but actually I don't understand why such result. It is also strange for me because the
PATH
environment variable is relevant once in the shell script.Thanks in advance for your help!
BR,
Vincent
The text was updated successfully, but these errors were encountered: