Fix exit codes

This commit is contained in:
jpic 2021-04-24 14:00:27 +02:00
parent 44dd1bc6a6
commit bcbe66a37f
4 changed files with 47 additions and 6 deletions

View File

@ -16,6 +16,12 @@ build-itself:
script: python3 ./shlaxfile.py build push=docker://docker.io/yourlabs/shlax:$CI_COMMIT_REF script: python3 ./shlaxfile.py build push=docker://docker.io/yourlabs/shlax:$CI_COMMIT_REF
stage: test stage: test
test-exitcode:
image: yourlabs/shlax:$CI_COMMIT_SHORT_SHA
script:
- tests/shlaxfail.py build || [ $? -eq 1 ]
- tests/shlaxsuccess.py build
test: test:
image: yourlabs/python image: yourlabs/python
stage: build stage: build

View File

@ -60,13 +60,13 @@ class Command(cli2.Command):
except ProcFailure: except ProcFailure:
# just output the failure without TB, as command was already # just output the failure without TB, as command was already
# printed anyway # printed anyway
self.exit_code = 1 pass
self['target'].value.output.results(self['target'].value)
if result and result.status == 'success': if self['target'].value.results:
self.exit_code = 0 if self['target'].value.results[-1].status == 'failure':
else: self.exit_code = 1
self.exit_code = 1 self['target'].value.output.results(self['target'].value)
return result
class ActionCommand(cli2.Command): class ActionCommand(cli2.Command):

18
tests/shlaxfail.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
"""
Shlaxfile for shlax itself.
"""
from shlax.shortcuts import *
shlax = Container(
build=Buildah(
Packages('prout', upgrade=False),
base='alpine',
commit='shlaxfail',
),
)
if __name__ == '__main__':
print(Group(doc=__doc__).load(shlax).entry_point())

17
tests/shlaxsuccess.py Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python
"""
Shlaxfile for shlax itself.
"""
from shlax.shortcuts import *
shlax = Container(
build=Buildah(
base='alpine',
commit='shlaxsuccess',
),
)
if __name__ == '__main__':
print(Group(doc=__doc__).load(shlax).entry_point())