Skip to content

.cmd file from rez suite cannot return correct code in Powershell #1361

Open
@yanshil

Description

@yanshil

Is there any consideration for using goto :eof rather than exit /b %errorlevel% in rez suite execution script generation (here: execution.py)? Our team is using GitLb powershell runner to do the deployment, and found out that $LASTEXITCODE is not correct when using rez suite script.

In my test, the Powershell $LASTEXITCODE will not be as expected until I changed goto :eof to exit /b.

suite context executagle snapshot

Environment

~platform==windows           (implicit)
~arch==AMD64                 (implicit)
~os==windows-10.0.18362.SP0  (implicit)

To Reproduce

  1. Start from hello_world
  2. New hello_world/bin/hello_world.bat (it is gonna to simply executing the python hello_world/python/hello_world.py)
python %~dp0../python/%~n0.py %*
  1. Build this pacakge
  2. Create a rez-suite like in https://github.com/AcademySoftwareFoundation/rez/wiki/Suites
rez-suite --create test_suite
rez-env hello_world --output tmp.rxt
rez-suite --add tmp.rxt --context hello_world test_suite
  1. Explicitly raise some exception in hello_world/bin/hello_world.py, run test_suite/bin/hello_world in both cmd and powershell

Expected behavior
cmd have %errorlevel% = 1

powershell should have $LASTEXITCODE = 1

Actual behavior
powershell now have $LASTEXITCODE = 0

Different return code in cmd and powershell

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions